New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dynamic import naming doesn't work #4861
Comments
Try with an '='
|
doesn't work. |
Same problem. |
To be clear, I use the latest webpack(2.5.1) in my project. The I added |
I use this feature (2.5.1) and it works fine to me. The only difference is that I don't have the '@' inside the path of my dynamic module; instead I have a relative path. |
@ematipico '@' is an alias for 'src', I've tested it is not relevant to this. |
I also set an alias for path, so it fails here? |
I have the same problem |
It works for me without the |
I've encountered this and it turned out I had to set output.chunkFilename in my webpack config |
@probablyup |
This is not related to Webpack as @MarvinXu is using |
Same problem. Does someone find the solution? |
I also have this problem, does someone resolve this issue? |
The problems were related to bad configuration inside the project. At the moment I am heavily using this feature and I don't have issues. What your problem? Care to share some code of how you use the |
This problem is caused by babel configuration More details please see vuejs-templates/webpack#730 |
Same issue. Was suspecting babel but even with my .babelrc with |
Okay gotcha: I set |
in my case i was using typescript so 1 it was removed the comments, 2 it was transforming the import to a promise ... setting |
Set the comment in .babelrc to false.
|
A combo of comments: true in .babelrc and webpack config to include chunkFilename = '[name].js' did the trick. |
If you are using TypeScript, please also ensure that you don't have this option in your {
"compilerOptions": {
"removeComments": true
}
} Let the removal of the comments to another plugin/loader, like UglifyJS. This option is only useful if you're not using a complex build tool, which is obviously not the case if you're reading this issue :) |
Update: I was using babel-plugin-dynamic-import-webpack instead of babel-plugin-dynamic-import. Similar tools, but they work at different levels. ===== I'm also having issues with webpackChunkName with a simple test project. I have chunkFilename and don't strip comments. It always generates a 0.bundle.js
I feel so close! I'm simply separating the login page from the rest of the app. |
@mikeaustin you know what.. one of my latest project which was working before out of suddenly started to output 0. 1. bundler names too! it might be a bug with latest version of webpack.. try downgrading it a bit see if that works for you |
Following @milewski, This works, bundle is split
This does not, one bundle to all imports.
The issue seems' to be in I've inspected the code emited, first
now
Clearly,
I've also tried to explicitly set Is it a template thing in webpack configuration? or this is just how it should work? Seems odd |
This is weird because For now i'm just using |
It's very odd so, on typescript and webpack with module esnext dynamic import is worked, and on just JavaScript and webpack dynamic import is not worked , with babel-plugin-dynamic-import too |
@shlomiassaf r u using Typescript when you write
|
In my TypeScript+Webpack case, |
To sum up, make sure you set:
If you are using typescript, also make sure:
This works for me and here is my commit for adding dynamic import (code split) support to my react-typescript project, hope it helps :) |
In case anyone else runs into this issue. I was using |
I set comments:false, my comments in code is removed, but non-entry module's webpackChunkName is not affected. |
FYI make sure you are not importing desired chunk "directly" somewhere else in code. |
@Armour's last comment worked for me, but note that [you may need to also add |
Can you make it just dynamically import a file just purely based on the text string and let the user do the chunking themselves instead of having webpack mangle the names for you? That's what I'd really like to do. |
Still not working with import(). Works only with (chunkFilename is set)
|
mark !!!! |
I am also facing trouble with just |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
I used comment to define chunkname as follows:
But in build report there is no chunk name specified and still generate filename as 1.[hash].js
If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/MarvinXu/webpack-chunkname-test
The text was updated successfully, but these errors were encountered: