madge: Annotated dynamic import causes crash
When using webpack annotations for dynamic imports, madge tries to make sense of the first argument to the import, which will be undefined.
So:
const Graph = React.lazy(() => import(/* webpackChunkName: 'react-graph-vis' */ `react-graph-vis`))
causes
✖ TypeError: Cannot read property 'lastIndexOf' of undefined
at Object.startsWith (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:2025:20)
at mangleScopedPackageName (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:27283:16)
at mangleScopedPackageNameWithTrace (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:27270:23)
at loadModuleFromImmediateNodeModulesDirectory (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:27195:83)
at /Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:27172:39
at Object.forEachAncestorDirectory (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:12577:26)
at loadModuleFromNearestNodeModulesDirectoryWorker (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:27166:19)
at loadModuleFromNearestNodeModulesDirectoryTypesScope (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:27162:16)
at tryResolve (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:27348:28)
at classicNameResolver (/Users/torgeir/dev/signatu/signatu/node_modules/typescript/lib/typescript.js:27324:24)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 15 (3 by maintainers)
Just change all the dynamic
import(calls to be static import statements at the top, run madge, git stash the conversion ofimport(calls (or put it on a branch).Getting the same issue, typescripts
import(...)gives the above mentioned errorI don’t know @villelaitila But it’s worth trying. If they refuse to fix it we can start working on some sort of workaround in Madge.