Importing modules using ES6 syntax and dynamic path [duplicate]

No, this is not possible. ES6 modules need to be able to statically resolve their dependencies, without executing module code, so that import statements do work reliably. The module specifier must be a string literal.

However, the module loader of your choice should support dynamic loading of modules with variable names. You wouldn’t be able to get a bound app identifier in your module scope however (and cannot reexport it), it typically would only be available in a callback or so.

Leave a Comment