-
Notifications
You must be signed in to change notification settings - Fork 512
[bug] async js chunks that include css/scss imports cause => Uncaught (in promise) TypeError: Cannot read property 'call' of undefined #456
Comments
I'm having the very same issue! Been trying to debug it a bit, but no luck so far. AFAIK the code for Child deps of that css file are processed https://github.com/webpack/webpack/blob/master/lib/Compilation.js#L506 and it seems that the original, non-extracted css module is removed(might be wrong here). And this in turn removes the reasons for the I'm not really familiar with webpack internals so it's hard to pinpoint the exact location of the issue, some help would be greatly appreciated. |
Was kinda right... Two files are missing in the bundle - |
is there any update on this? Issues still remains with wepback 3.1.0 and ETP 3.0.0 |
@ericnoguchi wip |
@ericnoguchi what about set new ExtractTextPlugin({
filename: '[name].css',
allChunks: true
}) |
That is what we are doing for the time being but ideally we would like to be able to lazy load css modules that are included in async JavaScript chunks |
@ericnoguchi Looks like an error, looking for a solution, thanks! |
@ericnoguchi what about this ( new webpack.optimize.CommonsChunkPlugin({
names: ['common', 'vendor', 'webpackBootstrap'],
async: true
}) |
If anyones interested I've got a temp fix working by excluding webpack.config.js
|
See the following link for context: webpack-contrib/extract-text-webpack-plugin#456 (comment)
This really making extract text plugin unusable when using Code Splitting. This issue along with #120 prevent the use of allChunks:false and make css splitting completely broken. |
@prannayb can you provide minimum reproducible test repo? |
+1 this is affecting our team too.
@kostasmanionis I tried your solution, but I'm hitting a problem. I'm excluding |
I got around the above mentioned issue by also excluding all CSS/LESS/SCSS from the common chunking too. |
I worked around the problem by adding |
Good find! I tested your solution with the repo above and so far the error is gone and the css dynamically loads e.g.
|
This bug bit me on upgrading to Webpack 4 with the new splitChunks stuff. This thread lead me in the right direction, but the suggestions didn't make a difference. But they did get me on the right track. I ended up requiring those two files within my app.
They were then correctly added to a bundle and were available for webpack to load on entry. EDIT: this fix doesn't solve the issue and the error persists in subsequent rebuilds. |
@payne8 same issue with webpack4 here - adding those lines fixes issue with chunks for me, but solution looks so unreliable |
@pleerock Looks like my fix only temporarily fixed the problem. It is super odd because if you modify and save a file and let webpack do an incremental build the issue goes away. But I can't do that for a production build. I edited my comment to reflect my experience. |
I am getting this issue as well - is there any sign of a fix? |
Getting this issue too, no fix on the sight? |
Looking at one PR referenced above seems like they have a working fix (works for me too), also similar to the solutions proposed in this page, but placing the entry: {
main: [
'your-app.js',
'style-loader/addStyles',
'css-loader/lib/css-base',
]
} |
…tract-text-plugin breaks page loading in conjunction with dynamic-import
I came across this bug as well and haven't been able to fix this. Adding the loaders like mentioned in the comment above does work, but I don't want to have this in production. The |
@JeroenReumkens Unfortunately, your solution was the only one that worked for me as well! Thanks for the short term fix. |
Not sure if this'll help anyone, but I had the same problem, which went away when I switched from Took me quite a while to realize that you're not meant to use |
I've tried all the workarounds above, and none have worked for me. In my case a dependency in node_modules loads its own sass, and when running the app (using next.js with next-sass [e.g. with mini-css-extract-plugin]) in development mode, when navigating between pages, webpack dynamically builds the resources, but then throws the error mentioned in this issue ( |
So, I just ran into this bug today while using create-react-app. Short of ejecting and trying some of the web pack config changes above, the only solution that worked reliably for me was to move the css imports to the root of the app to avoid any async css imports. |
DEPRECATED |
Tested with
ETP:2.1.0
webpack: 2.2.1
Node v7.7.1
There seems to be some issue when importing a scss file in a common chunk if that common chunk also imports an async/dynamic js chunk which imports another scss file.
File setup
This issue happens when allChunks:false [I would like to lazy load js and associated css], and what seems to be happening is that the runtime code for css-loader is not always being included in the bundle which results in the below error?
But if I for example update common.scss while webpack-dev-server is running, when the bundle gets rebuilt and the page refreshes I can see the code for css-loader in the chunk and the error goes away, but if I restart webpack-dev-server again and refresh the error comes back and css-loader code is gone.
I have created a repo with showing this error
https://github.com/ericnoguchi/webpack-testing
steps to reproduce.
Link stack overflow issue:
http://stackoverflow.com/questions/42687881/async-js-chunks-that-include-scss-imports-cause-uncaught-in-promise-typeerr
The text was updated successfully, but these errors were encountered: