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

TypeError: Cannot read property 'identifier' of undefined #91

Closed
legomushroom opened this issue Jan 26, 2017 · 3 comments
Closed

TypeError: Cannot read property 'identifier' of undefined #91

legomushroom opened this issue Jan 26, 2017 · 3 comments

Comments

@legomushroom
Copy link

Having this error after moving to webpack2.

Entire log:

/Applications/MAMP/htdocs/Glimpse.Client/node_modules/hard-source-webpack-plugin/lib/hard-context-module-factory.js:76
    var identifier = identifierPrefix + module.identifier();
                                              ^

TypeError: Cannot read property 'identifier' of undefined
    at /Applications/MAMP/htdocs/Glimpse.Client/node_modules/hard-source-webpack-plugin/lib/hard-context-module-factory.js:76:47
    at /Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/lib/ContextModuleFactory.js:37:22
    at /Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/node_modules/tapable/lib/Tapable.js:204:11
    at ContextModuleFactory.cmf.plugin (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/lib/IgnorePlugin.js:30:13)
    at ContextModuleFactory.applyPluginsAsyncWaterfall (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/node_modules/tapable/lib/Tapable.js:208:13)
    at ContextModuleFactory.create (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/lib/ContextModuleFactory.js:26:7)
    at next (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/hard-source-webpack-plugin/lib/hard-context-module-factory.js:59:15)
    at HardContextModuleFactory.create (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/hard-source-webpack-plugin/lib/hard-context-module-factory.js:66:3)
    at iteratorFactory (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/lib/Compilation.js:209:12)
    at /Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/node_modules/async/dist/async.js:3025:16
    at eachOfArrayLike (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/node_modules/async/dist/async.js:941:9)
    at eachOf (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/node_modules/async/dist/async.js:991:5)
    at Object.eachLimit (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/node_modules/async/dist/async.js:3089:3)
    at Compilation.addModuleDependencies (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/lib/Compilation.js:190:9)
    at Compilation.processModuleDependencies (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/lib/Compilation.js:175:8)
    at _this.buildModule.err (/Applications/MAMP/htdocs/Glimpse.Client/node_modules/webpack/lib/Compilation.js:315:13)

This is the plugin's config:

// ...
new HardSourcePlugin({
   cacheDirectory: `${dirname}.cache/[confighash]`,
   recordsPath: `${dirname}.cache/[confighash]/records.json`,
   configHash: function configHash(webpackConfig) {
       return require('node-object-hash')().hash(webpackConfig);
   },
   environmentHash: {
       root: `${process.cwd()}/`,
       directories: ['node_modules'],
       files: ['package.json']
   }
}),
// ...

Will appreciate any help!

@mzgoddard
Copy link
Owner

@legomushroom I was looking at this earlier to start mulling over what is going on. This is frankly super weird. This error implies that the function erroring is getting no values when its called. No error or module. If the wrapped factory found no module, I think it is supposed to give an error which the function will forward.

Is there any more of your config you can share?

@legomushroom
Copy link
Author

Hi @mzgoddard!

Thanks for the response.
I figured out the exact problem. I was using webpack.IgnorePlugin (for moment.js issue) like this:

new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)

This caused the error. Yep, both error and module were undefined. Works like a charm after removing the IgnorePlugin.

@mzgoddard
Copy link
Owner

mzgoddard commented Jan 26, 2017 via email

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

2 participants