question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack's IgnorePlugin causes an "TypeError: Cannot read property 'identifier' of undefined"

See original GitHub issue

Do you want to request a feature or report a bug? Bug.

What is the current behavior? Using webpack.IgnorePlugin causes compilation to fail with a TypeError: Cannot read property 'identifier' of undefined message. The full stack trace:

C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compilation.js:250
                const identifier = module.identifier();
                                          ^

TypeError: Cannot read property 'identifier' of undefined
    at Compilation.addModule (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compilation.js:250:29)
    at moduleFactory.create (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compilation.js:597:34)
    at hooks.beforeResolve.callAsync (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\NormalModuleFactory.js:278:23)
    at AsyncSeriesWaterfallHook.eval [as callAsync] (eval at create (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:18:1)
    at AsyncSeriesWaterfallHook.lazyCompileHook [as _callAsync] (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\Hook.js:35:21)
    at NormalModuleFactory.create (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\NormalModuleFactory.js:268:28)
    at semaphore.acquire (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compilation.js:577:18)
    at Semaphore.acquire (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\util\Semaphore.js:16:4)
    at Compilation._addModuleChain (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compilation.js:576:18)
    at Compilation.addEntry (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compilation.js:657:8)
    at compiler.hooks.make.tapAsync (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\SingleEntryPlugin.js:30:16)
    at AsyncParallelHook.eval [as callAsync] (eval at create (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:7:1)
    at AsyncParallelHook.lazyCompileHook [as _callAsync] (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\Hook.js:35:21)
    at hooks.beforeCompile.callAsync.err (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compiler.js:434:20)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\Hook.js:35:21)
    at Compiler.compile (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compiler.js:427:28)
    at readRecords.err (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compiler.js:217:11)
    at Compiler.readRecords (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compiler.js:324:11)
    at hooks.run.callAsync.err (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compiler.js:214:10)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\Hook.js:35:21)
    at hooks.beforeRun.callAsync.err (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compiler.js:211:19)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:15:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\tapable\lib\Hook.js:35:21)
    at Compiler.run (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack\lib\Compiler.js:208:24)
    at processOptions (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack-cli\bin\webpack.js:469:20)
    at yargs.parse (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack-cli\bin\webpack.js:472:3)
    at Object.parse (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\yargs\yargs.js:539:18)
    at C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack-cli\bin\webpack.js:196:8
    at Object.<anonymous> (C:\dev\workspaces\labtime\design-system\webpack-postcss-cssnext\node_modules\webpack-cli\bin\webpack.js:474:3)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)

If the current behavior is a bug, please provide the steps to reproduce. I put up an isolated test case on GitHub: https://github.com/lodybo/webpack-ignoreplugin-iso-testcase.git

There are 2 config files: the normal one (which compiles css files), and a smaller alternate config. I used the alternate one to provide an isolated test case: npm run webpack -- --config webpack.config-alt.js

What is the expected behavior? Expected behaviour is that compilation succeeds, and that the file specified by the regex (theme.js) is not emitted.

If this is a feature request, what is motivation or use case for changing the behavior? See above.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System. OS: Windows 10 pro Node version: 8.9.4 NPM: 5.6.0 Webpack: 3.10.0 (I also tried this with 4.0.0-beta.0, with the same result).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
alexander-akaitcommented, May 6, 2018

webpack@4 also have this problem

1reaction
mach-kernelcommented, Feb 26, 2018

This issue also affects me, same exact versions as @lodybo

Usage:

  plugins: [
    new webpack.IgnorePlugin(/vertx/)
  ]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack: TypeError: Cannot read property ... - Stack Overflow
I completed step 1, however yarn install produces this error: error upath@1.0.4: The engine "node" is incompatible with this module. Expected ...
Read more >
IgnorePlugin - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
webpack/webpack/dev - Gitter
This means that the following logic is flawed and the reload falls over, with error Error TypeError: Cannot read property 'filter' of undefined....
Read more >
Angular 12 Support #14909 - Issuehunt
TypeError : Cannot read property 'minify' of undefined ERR! at ... In my case the webpack 4 dependencies seem to be causing issues...
Read more >
You can add it into package.json
... TypeError: Cannot read property ... webpack 5.21.2 compiled with 1 error and 1 ... node_modules/sass-loader/dist/cjs.js): SassError: Undefined variable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found