Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Breaks in Webpack 4 with name option #69

Closed
statianzo opened this issue Jan 30, 2018 · 1 comment
Closed

Breaks in Webpack 4 with name option #69

statianzo opened this issue Jan 30, 2018 · 1 comment

Comments

@statianzo
Copy link
Contributor

Using bundle-loader and specifying a name throws an error in Webpack 4.

import other from 'bundle-loader?lazy&name=myChunk!./other';

fails compilation with the error

ERROR in ./node_modules/bundle-loader?lazy&name=myChunk!./src/other.js

Module build failed: TypeError: Cannot read property 'context' of undefined

    at Object.module.exports.pitch (/app/node_modules/bundle-loader/index.js:13:43)

@ ./src/index.js 1:0-60 3:0-5

It appears that Webpack 4 is not setting this.options when invoking loader functions. From bundle-loader source:

var options = {
  context: query.context || this.options.context, // <-- Cannot read property 'context' of undefined
  regExp: query.regExp
};

I'd be glad to make a PR to fix this, but I'm not sure if the problem is a Webpack 4 issue or bundle-loader. If it's bundle-loader's issue, what's the desired behavior?

Versions

Webpack: 4.0.0-beta.0
bundle-loader: 0.5.5

Example

Glitch.me project that reproduces the error

@statianzo
Copy link
Contributor Author

According to the Webpack Medium that this.options was deprecated in Webpack 3 and removed in 4.

https://medium.com/webpack/webpack-4-migration-guide-for-plugins-loaders-20a79b927202

Its replacement should be this.rootContext. I'll put together a PR for that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant