0

I'm not sure if it's document somewhere but I was wondering if there's any way to use import of ES2015 as an expression. The only thing I've seen it being used is with statements.

e.g. in CJS I can do this:-

require('someArray').map(arr=>arr+1);

but I haven't quite figured out how to do that with import. All I can think of is:-

import * as someArray from 'someArray';
someArray.map(arr=>arr+1);

Is it something that isn't possible with new import keyword?

shriek
  • 5,605
  • 8
  • 46
  • 75
  • import statements are used in static analysis, there's no place for expressions. Every possible combination is likely to be listed here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import – Estus Flask Jul 15 '16 at 19:27
  • @estus Ah, I see the reason for it not being an expression now. Thank you. If you can use that as an answer I'll go ahead and close this. – shriek Jul 15 '16 at 19:32

0 Answers0