Running into an issue with converting to ES6 import I haven't found a solution from searches but traditionally I was able to create a Promise as:
Promise.all([
  require('../path/to/a')('foo'),
  require('../path/to/b')('bar'),
])
  .then(() => {
    // further code
  })
  .catch(e => {
    console.log(e.message)
  })
and switching to ES6 I have to write my Promise as:
import a from '../path/to/a'
import b from '../path/to/b'
Promise.all([
  a('foo'),
  b('bar'),
])
  .then(() => {
    // further code
  })
  .catch(e => {
    console.log(e.message)
  })
for it to work but if I try to import and run on one line:
Promise.all([
  import('../path/to/a')('foo'),
  import('../path/to/b')('bar'),
])
  .then(() => {
    // further code
  })
  .catch(e => {
    console.log(e.message)
  })
I get:
ImportCall('../path/to/a') is not a function
Research
- react and flow: import Node type and PureComponent in one line
- Coffeescript: How to import express module in one line
- How to run a file with imported ES6 modules in Node
- How to run functions from Command Line in Node module
- Run factory function on import in TypeScript?
- Run function in script from command line (Node JS)
Is there a way to import and run a module in one line since that would be the only instance I would need a() and b()? Note I am not using TypeScript but my search for a solution resulted in many TypeScript Q&As.
