Skip to content

Cannot read property 'pop' of undefined #505

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

Closed
purple-force opened this issue Feb 25, 2020 · 4 comments
Closed

Cannot read property 'pop' of undefined #505

purple-force opened this issue Feb 25, 2020 · 4 comments

Comments

@purple-force
Copy link

  • Operating System: macOS Catalina 10.15.2

  • Node Version: 10.16.0

  • NPM Version: 6.9.0

  • webpack Version: 4.17.2

  • mini-css-extract-plugin Version: 0.9.0

Expected Behavior

A spa demo with two pages https://github.com/purple-force/mini-css-issue.

page1.jsx and page2.jsx is loaded by react-loadable in index.jsx, where react-loadable's loading is set to () => <Loading />. loading.jsx import loading.css. It will not throw above error if import './loading.css' is removed.

The error is from https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/index.js#L498, where bestMatch is undefined.

what expected is js, css files in build directory after run build with name set by output.filename and new MiniCssExtractPlugin's option filename. and css contents are in one file.But if chunkFilename is set,filename will be invalid.

Actual Behavior

Cannot read property 'pop' of undefined
image

@fivethreeo
Copy link

#487 Got the same problem, any idea to the cause?

@khades
Copy link

khades commented Mar 20, 2020

more likely this #341

@alexandrukis
Copy link

alexandrukis commented Mar 26, 2020

This happens because your entry point shares its name with the cache group

entry: {
    index: './src/index.jsx',
},
...
cacheGroups: {
    indexStyles: {
        name: 'index',
        test: (m, c, entry = 'index') => {
            return m.constructor.name === 'CssModule' && recursiveIssuer(m) === entry;
         },
         chunks: 'all',
         enforce: true,
    }
}

Try changing your cacheGroups definition to this, see if it works:

cacheGroups: {
    index: {
        name: 'indexStyles',
        test: (m, c, entry = 'index') => {
            return m.constructor.name === 'CssModule' && recursiveIssuer(m) === entry;
         },
         chunks: 'all',
         enforce: true,
    }
}

@alexander-akait
Copy link
Member

alexander-akait commented Aug 13, 2020

Answer above, it will be an error in webpack@5 by default, we can't fix it on our side, sorry

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

5 participants