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
Dynamic imports with a dynamic expression (e.g. import(/* webpackMode: "lazy" */ `./${name}`)) are not chunked and/or loaded correctly when called from a TypeScript file, even if explicitly using the 'lazy' mode.
They work correctly when done from a JavaScript file leading me to think the bug is in ts-loader.
Example repo at the bottom.
Expected Behaviour
A chunk should be built for every separate .ts file; a.ts, b.ts and c.ts. Calling import should only load the chunk associated with that .ts file.
This works when the dynamic import is done from a .js file.
Actual Behaviour
a.ts, b.ts and c.ts are put together in the same chunk. In our actual application, they are put in separate chunks (because of the sizes?), but all of them are loaded at the same time when the dynamic import is done instead of only the chunk for the requested module, resulting in hundreds of requests.
Steps to Reproduce the Problem
Run npm install && npm run build in the linked repo. You can see that only one file called Content_sync_recursive_.js is created in the build folder instead of three separate ones.
Location of a Minimal Repository that Demonstrates the Issue.
The text was updated successfully, but these errors were encountered:
gliptic
changed the title
Dynamic imports with a dynamic expressions are not chunked/loaded correctly
Dynamic imports with a dynamic expression are not chunked/loaded correctly
Oct 20, 2023
Dynamic imports with a dynamic expression (e.g.
import(/* webpackMode: "lazy" */ `./${name}`)
) are not chunked and/or loaded correctly when called from a TypeScript file, even if explicitly using the 'lazy' mode.They work correctly when done from a JavaScript file leading me to think the bug is in ts-loader.
Example repo at the bottom.
Expected Behaviour
A chunk should be built for every separate .ts file; a.ts, b.ts and c.ts. Calling import should only load the chunk associated with that .ts file.
This works when the dynamic import is done from a .js file.
Actual Behaviour
a.ts, b.ts and c.ts are put together in the same chunk. In our actual application, they are put in separate chunks (because of the sizes?), but all of them are loaded at the same time when the dynamic import is done instead of only the chunk for the requested module, resulting in hundreds of requests.
Steps to Reproduce the Problem
Run
npm install && npm run build
in the linked repo. You can see that only one file called Content_sync_recursive_.js is created in thebuild
folder instead of three separate ones.Location of a Minimal Repository that Demonstrates the Issue.
https://github.com/gliptic/dynamicimportbug
The text was updated successfully, but these errors were encountered: