Purgecss: chunk.mapModules is not a function

Created on 26 Jan 2018  路  7Comments  路  Source: FullHuman/purgecss

Before you open an issue, please check if a similar issue already exists or has been closed before.

When reporting a bug, please be sure to include the following:

  • [x] A descriptive title
  • [ ] An isolated way to reproduce the behavior (example: GitHub repository with code isolated to the issue that anyone can clone to observe the problem)
  • [x] What version of purgecss you're using, and the platform(s) you're running it on
    "purgecss-webpack-plugin": "^0.19.0"
    Windows 7
  • [x] The behavior you expect to see, and the actual behavior
    not crashing when npm run build
new PurgecssPlugin({
  paths: [path.resolve(__dirname, './dist/index.html'), ...glob.sync(path.resolve(__dirname, './src/*'))],
})

dist/ is the bundle output folder
src/ is where the React components go.

output:

...
C:\dev\projects\webui\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:148
    return chunk.mapModules(function (module) {
                 ^

TypeError: chunk.mapModules is not a function
    at files (C:\dev\projects\webui\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:148:18)
    at C:\dev\projects\webui\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:199:90
    at Array.forEach (<anonymous>)
    at C:\dev\projects\webui\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:195:39
    at Array.forEach (<anonymous>)

Can you spot what could be causing this error? Thanks

Need more information

Most helpful comment

@CanbingChen this should fix your issue:
In your config of purgecss add the option { nodir: true } into glob, like this:
paths: glob.sync('${PATHS.src}/*', { nodir: true })

All 7 comments

Thank you for reporting this issue.
What version of webpack are you using? webpack -v
Would you be able to create a minimal repo to reproduce the bug?

I've got the same error

I've got the same error锛宮y webpack version is 3.0.0

@CanbingChen can you update webpack to the latest version 3.10 and see if the error is still present?

Please continue this thread over here https://github.com/FullHuman/purgecss-webpack-plugin/issues/11 since this is a duplicate.

@Ffloriel I've got the error after update webpack.the terminal show "illegal operation on a directory, read"

@CanbingChen this should fix your issue:
In your config of purgecss add the option { nodir: true } into glob, like this:
paths: glob.sync('${PATHS.src}/*', { nodir: true })

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eldiegod picture eldiegod  路  4Comments

TylerBarnes picture TylerBarnes  路  5Comments

chuckyblack picture chuckyblack  路  3Comments

knowler picture knowler  路  3Comments

XhmikosR picture XhmikosR  路  9Comments