0

This is just something short I have not been able to find out while I've been re-writing my app to be ES6-ready:

Say I had a function with a paramater router exported from a model './app/routes/api' and I wanted to import it in my main app.js with the syntax import 'a' from b, but pass the router Paramater (that has been pre-defined as let router = express.Router(); with it, so that it would be var apiRoutes = require('./app/routes/api')(router); in CommonJS require statements. How could you do that in ES6?

Max H.
  • 45
  • 1
  • 7
  • No way to get the same behavior with the `import` syntax. The `require` version will work regardless. – Balázs Édes Jan 23 '17 at 20:58
  • Writing the function with a default argument is an approach to consider. But it certainly wouldn't be equivalent to what you're describing and might not be practical depending on the function. – fvgs Jan 23 '17 at 21:03

0 Answers0