-
-
Notifications
You must be signed in to change notification settings - Fork 384
TypeError: Cannot read property 'split' of undefined #205
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
Comments
I'm not using webpack-i18n-extractor-plugin but I am getting the same error. It's also in
This is the problem line:
I don't really know my way around the code base but I'd suggest to the author might it help to add a guard clause to test for a valid this._identifier before attempting the split? Maybe update the code to something like this?
Edit: I've wound back my version to 0.4.0 and then 0.3.0 and same error occurs. |
FYI, there was a related issue in webpack-i18n-extractor-plugin repository. It was fixed by the author. You can read the explanation of the fix there. |
I was having the same issue, but ive found the solution. Before notice CleanCss Loader was between MiniCss, and css-loader, and this was causing the bug. After |
I ran into this recently. I didn't realize that |
Don't use |
I was having the same error, but had the order of loaders as described here. After much searching I found out that the culprit was the This comes from the official documentation of
|
@naoisegolden You are absolutely right. Just as you say, the culprit was the |
i had same error, and i found a solution on stackoverflow. I changed format from { loader: "css-loader" } to "css-loader" |
In the loaders, have you tried adding module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
// you can specify a publicPath here
// by default it uses publicPath in webpackOptions.output
publicPath: '../',
hmr: process.env.NODE_ENV === 'development',
},
},
+ 'css-loader',
],
},
],
}, |
Somebody can create minimum reproducible test repo? |
@evilebottnawi here's a test repo - https://github.com/hellatan/webpack-mini-css-bug I've been digging around and it seems like it has to do with how webpack is compiling the assets from my observations. I'm also using css modules for my config. Just for reference, then I mention
When I mentions
In the string configuration, you can even do this:
and it will act like the string option. Now that that setup is out of the way, from what I can tell, the following is getting set to
When
By having the latter shape, this error is not thrown. I was really trying to track this problem, but I'm really not familiar with how webpack internally handles module rule settings and loaders. I saw that output from src/loader.js#L122 is different when using the The
The string configuration output something like this:
The most significant difference is that the string config has this Hopefully all of this info helps out as i'm stuck on [email protected] for the time being because I need to pass options into our css-loader. I think this issue even popped up when upgrading to [email protected]. |
Bump, still having this issue with no solution... |
bump, also running into this issues with onlyLocals: true |
bump, I am also having this issue with onlyLocals: true, really need it for my SSR :( |
Have anyone try extract-css-chunks-webpack-plugin instead? I tried and it worked in my case as I need to extract CSS from js bundle which used |
This comment has been minimized.
This comment has been minimized.
Happen to me for [email protected] webpack.config.js
|
Check your |
error didn't happen when Anyway errors shouldn't happen this way. If config file is not met some conditions, it should throw some human readable error with error reason. |
@ogonkov Can you create reproducible test repo? |
@evilebottnawi could the test repo from #205 (comment) be enough for you to test with? |
Here you go https://gist.github.com/ogonkov/d4060500cf3d5b8b78e61fac9b8befe9 |
@ogonkov thanks, bug, to be honestly you should not use |
I guess it should emit some warning in that case |
@ogonkov yep, I think about it, but it is hard to know what previously loader exports (when you use |
I use this webpack config and get the same error
I tried to use exportOnlyLocals: true and false, but it didn't help. The only solution is to downgrade css-loader to v3 (3.6.0) |
@fremail Please create reproducible test repo |
@fremail see if my repo works for your situation - https://github.com/hellatan/webpack-mini-css-bug |
@hellatan update deps and the same problem #205 (comment) |
@evilebottnawi the reproducible repo https://github.com/fremail/mini-css-bug |
@fremail sorry for delay, update |
@evilebottnawi yeah, css-loader@4 with mini-css-extract-plugin@1 and style-loader@2 works fine. Thank you! |
I'm also getting this error when using webpack 5. In the latest version 4 of webpack, everything was going nicely :/ : css-loader: 4.3.0 my rule : {
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { importLoaders: 1 } },
// {
// loader: 'postcss-loader',
// options: {
// postcssOptions: {
// ident: 'postcss',
// plugins: (): Record<string, unknown>[] => [postcssNormalize()]
// }
// }
// },
'sass-loader'
]
}, Stack trace : 75% sealing chunk optimization SplitChunksPlugin[webpack-cli] Uncaught exception: TypeError: Cannot read property 'split' of undefined
[webpack-cli] TypeError: Cannot read property 'split' of undefined
at CssModule.nameForCondition (/Users/blephy/Sites/strict-optimized-react-starter/node_modules/mini-css-extract-plugin/dist/CssModule.js:65:39)
at checkTest (/Users/blephy/Sites/strict-optimized-react-starter/node_modules/webpack/lib/optimize/SplitChunksPlugin.js:490:23)
at /Users/blephy/Sites/strict-optimized-react-starter/node_modules/webpack/lib/optimize/SplitChunksPlugin.js:447:7
at Object.fn [as getCacheGroups] (/Users/blephy/Sites/strict-optimized-react-starter/node_modules/webpack/lib/optimize/SplitChunksPlugin.js:464:5) Repository to reproduce (branch refacto) : https://github.com/blephy/reactjs-typescript-pwa/tree/refacto |
Exactly facing the same issue when moving to webpack 5 and i have the same configuration as u above. Were u able to find a solution. |
@darkangel081195 your report is not help to help you or solve the problem |
Can u please let me know, what should be provided to get some guidance on the above error. I have recently updated to css-loader 5.0.0 from version 1.0.1, My version for mini-css is 0.8.0
} |
@darkangel081195 Can you create reproducible test repo |
@evilebottnawi I put a link to a reproductible repository |
@blephy Can you describe how we can reproducible it? |
@evilebottnawi sure // fetch the repo
git clone https://github.com/blephy/reactjs-typescript-pwa.git
cd reactjs-typescript-pwa
// change branch to refacto
git checkout refacto
// install dependencies
npm i make a .env file at the root folder with this content : # Needed by the server and the app (CORS / SEO...)
DOMAIN_NAME=localhost:3001
PORT=3001
HTTPS=false
# Currently not exploited
API_URL=localhost:3001/api/v1
# Report URI https://report-uri.com/
CT_REPORT_URI=https://reactjstypescriptpwa.report-uri.com/r/d/ct/enforce
CSP_REPORT_URI=https://reactjstypescriptpwa.report-uri.com/r/d/csp/enforce
API_REPORT_URI=https://reactjstypescriptpwa.report-uri.com/a/d/g Run production build with webpack (config/webpack/app.prod.ts) : npm run build
@darkangel081195 no i didn't fixed it yet. |
@blephy bug with configuration, sorry your repository is very big, I do not have time to investigate what is wrong, because others need help too, also you have problems:
How to debug - https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/loader.js#L153 if (!dependency.identifier) {
console.log(dependency);
continue;
} |
Same fix in main branch, I will do release today, but if you faced with the issue again, feel free to open a new issue with reproducible test repo |
Face the issue but this one solve my problem
|
tried to use webpack-i18n-extractor-plugin together with mini-css-extract-plugin. The build fails with the following error:
When I remove WebpackI18nExtractorPlugin from the configuration, the build finishes successfully.
The simple project demonstrating this issue can be found here.
NodeJS version is 8.11.2
The text was updated successfully, but these errors were encountered: