Skip to content
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

Cannot read property 'pop' of undefined #143

Closed
Airkro opened this issue Jan 14, 2019 · 9 comments
Closed

Cannot read property 'pop' of undefined #143

Airkro opened this issue Jan 14, 2019 · 9 comments

Comments

@Airkro
Copy link

Airkro commented Jan 14, 2019

I am temporarily unable to provide a minimal project showing the problem. But maybe is the same problem with webpack-contrib/mini-css-extract-plugin#257.

  • node.js: 11.5.0
  • extract-css-chunks-webpack-plugin: ^3.3.2
  • webpack: ^4.28.0
@ScriptedAlchemy
Copy link
Collaborator

We are in the process of merging the two projects. So it’s very likely to exist in both. Can you isolate if this is due to node 11?

@Airkro
Copy link
Author

Airkro commented Jan 15, 2019

Not work in Linux with node.js 10.5.0 either.

@ScriptedAlchemy
Copy link
Collaborator

Can you tell me the last version it does work on? I’ll see if I can track down the issue and fix both plugins. Likely an issue with loader-utils

@Airkro
Copy link
Author

Airkro commented Jan 21, 2019

I think it has nothing to do with the version of node.js. Causing the problem might be the configuration of optimization.splitChunks and some specific packages. Once I have time I will try to organize a simple example.

@Airkro
Copy link
Author

Airkro commented Mar 5, 2019

After modifying optimization.splitChunks, this problem has not happened again, maybe I should close it.

@ScriptedAlchemy
Copy link
Collaborator

Would be great to document this in a pull request to our readme, what configuration caused it and what was the solution. I’ll also raise this with webpack and look at solving it

@laneme
Copy link

laneme commented Feb 20, 2020

This issue ran into me out of nowhere. Yea, i don't think it's something version specific either. My node version 13.8.0 and 13.9.0.
These are related package versions.

    loader-utils: "^1.2.3",
    mini-css-extract-plugin: "^0.9.0",
    webpack: "^4.41.5", "^4.41.6"

The error disappeared after i removed the line chunks: all from webpack spitchunks config.

I have no idea what it does but removing this i guess isn't an option. It causes all chunks to include those common codes that are supposed to be splitted and not included in any other file.

Everything was running fine yesterday. I did an system update yesterday (ubuntu) and no idea what related packages were updated. Probably something Node depends on and spread into mini-css.

I have no idea how to debug and get around this issue. Can't even uninstall Nodejs -_-

@laneme
Copy link

laneme commented Feb 20, 2020

Okay. So i figured out, at least in my case, that it's entirely configuration based issue. I mean this issue only appears on certain configs. I couldn't remove chunks: all either, which was removing the error.

So i created a new project. Quickly created files and configs that normally takes me decades to do so XD. The new project was working just fine. So no version specific problems i assumed. I started tweaking my config.

This was the entry of the common chunk.

entry: {
    common: [
        '/path/to/one/module'',
        'path/to/another/module'',
        //  ...
    ]
}

And this inside splitChunks. Notice the same naming 'common'.

cacheGroups: {
    common: {
        test: /common/, // name of the entry chunk
        name: 'common',
        chunks: 'all'
    }
}

All i had to do was change entry chunk name from common to something else, like general.

entry: {
    general: [
       '/path/to/one/module'',
    //  ...
]
}

//  ....

cacheGroups: {
    common: {
        test: /general/,
        name: 'common',
        chunks: 'all'
    }
}

That lead me to another issue, not really an issue i assume but something i don't understand. See this was the config for mini-css plugin.

new MiniCssExtractPlugin({
    filename: 'public/styles/[name].css',
    chunkFilename: '[id].css',
}),

Which was before outputting the common chunk to public/styles but after changed the name of the entry chunk to general, it was outputting in root of the dist folder. Means it wasn't outputting to filename. So i had to change the chunkFilename to my desired outputPath

chunkFilename: 'public/styles/[id].css'

But i have no idea why it was using the chunkFilename instead of filename all of a sudden.
Not sure if i explained well. @ScriptedAlchemy Any way i can gather more info? I sure don't want anyone to run into this annoying issue again in future.

@AnYueJS
Copy link

AnYueJS commented Jun 1, 2021

cacheGroups: {
    commons: {
      name: 'commons',
      chunks: 'all',
      minChunks: 2,
      priority: -20,
      **enforce: true**
     },
 },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants