You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the dynamic import syntax in Typescript code, only a constant file name can be referenced.
Using a variable does not transpile to correct module resolving.
Dynamic import should work the same when using either a constant file name or a variable file name.
😯 Current Behavior
when using import(fileVar) the file is not found as attempted to be loaded as is, without resolution.
This is because that code part is left as is, not transpiled the way as when import("fileConstant").
This allows lazy loading but prevents any real dynamic loading, where the name/path of module to load depends on runtime (from a user choice, typically).
🐛 bug report
When using the dynamic import syntax in Typescript code, only a constant file name can be referenced.
Using a variable does not transpile to correct module resolving.
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
Dynamic import should work the same when using either a constant file name or a variable file name.
😯 Current Behavior
when using
import(fileVar)
the file is not found as attempted to be loaded as is, without resolution.This is because that code part is left as is, not transpiled the way as when
import("fileConstant")
.💁 Possible Solution
The code with a variable should be transpiled the same way as the code with a constant:
🔦 Context
This allows lazy loading but prevents any real dynamic loading, where the name/path of module to load depends on runtime (from a user choice, typically).
💻 Code Sample
🌍 Your Environment
The text was updated successfully, but these errors were encountered: