Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack DllReferencePlugin is not working

I've got a problem with the DllReferencePlugin on one of my projects (I'm using Webpack 1.13.2). In particular, I have 3 pairs of manifests and bundle files generated by DllPlugin and in my plugins section for the main bundle I have 3 DllReferencePlugin sections:

entry: {    
  body: [
    './src/main.js',
  ],
},
...
plugins: [
...
    new webpack.DllReferencePlugin({
      context: process.cwd(),
      manifest: path.join(dllPath, 'commons-manifest.json'),
    }),
    new webpack.DllReferencePlugin({
      context: process.cwd(),
      manifest: path.join(dllPath, 'vendor-manifest.json'),
    }),
    new webpack.DllReferencePlugin({
      context: process.cwd(),
      manifest: path.join(dllPath, 'react-manifest.json'),
    }),    
]
...

When I try to run it I get the following error:

/node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js:43 if(request && request in this.options.content) { ^

TypeError: Cannot use 'in' operator to search for './src/main.js' in undefined

The same configuration works nice for my other project, so I think this error has something to do with the path resolution. I've tried relative paths for the context and manifest path but it does not work either.

like image 404
Voice Avatar asked Oct 29 '22 11:10

Voice


1 Answers

The problem was that for this particular version of Webpack (1.13.2) manifest: require(path.join(dllPath, 'commons-manifest.json')) should be used instead of manifest: path.join(dllPath, 'commons-manifest.json')

like image 127
Voice Avatar answered Jan 02 '23 21:01

Voice