How to conditionally import scripts per route with Flowrouter?


#1
FlowRouter.route('/marketing-hub', {
  name: "marketing_hub",
  action: function(queryParams) {
        import './ui/views/marketing-view.js';
  }
});

Something like this is not possible and throws an error Uncaught SyntaxError: Unexpected token import. How can we load files conditionally as we load a new route? I want to make sure to only load what is really needed per route.


#2

According to the guide you can still use require as import can only be in the beginning of the file.