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

Webpack 4: Cannot read property 'resolveUrlLoader' of undefined #79

Closed
acoll opened this issue Feb 20, 2018 · 16 comments
Closed

Webpack 4: Cannot read property 'resolveUrlLoader' of undefined #79

acoll opened this issue Feb 20, 2018 · 16 comments

Comments

@acoll
Copy link
Contributor

acoll commented Feb 20, 2018

It looks like loader.options is undefined on https://github.com/bholloway/resolve-url-loader/blob/master/index.js#L39 when using webpack 4.0.0-beta.2.

I'm not sure if this is a problem with resolver-url-loader or with webpack.

@ranyitz
Copy link

ranyitz commented Feb 21, 2018

@acoll This is something that was removed in webpack 4

this.options and this.rootContext
webpack 3 already deprecated this.options in the loader context. webpack 4 removes it now.

Guideline: Loaders should receive all options via this.query. They should not use other ways to receive options, i. e. no property in webpack options, no environment variable.

@bholloway This is breaking for people that try to migrate to webpack 4.

+1 for #80

@acoll
Copy link
Contributor Author

acoll commented Feb 21, 2018

Ok cool. Could you link to where you pulled that guideline? So based on that should the options be computed as defaults(loader.query, {/* ... the defaults */})?

I tried that and it seems to make more sense than my other change and loader.query contains the options i'm setting in my webpack config.

@ranyitz
Copy link

ranyitz commented Feb 21, 2018

Unfortunately, there are no specific anchors, but it's in the release notes of webpack 4.

About your comment, loaderUtils actually does that.

@petrleocompel
Copy link

Now when webpack 4.0.0 was released.
See also Breaking changes for plugins/loaders on release page.

@bholloway
Copy link
Owner

bholloway commented Feb 25, 2018 via email

@julkue
Copy link

julkue commented Mar 1, 2018

@d2phap
Copy link

d2phap commented Mar 2, 2018

I have the same issue after upgrading to Webpack 4

@julkue
Copy link

julkue commented Mar 3, 2018

@bholloway What's the status?

@hadnet
Copy link

hadnet commented Mar 3, 2018

Same thing here. Any news?

@dmaicher
Copy link

dmaicher commented Mar 3, 2018

I'm using this fix temporarily:

https://github.com/dmaicher/resolve-url-loader/commit/1e9d6f046e7efb80988a3f8b4da89067036d6127

"resolve-url-loader": "github:dmaicher/resolve-url-loader#1e9d6f046e7efb80988a3f8b4da89067036d6127"

@bholloway
Copy link
Owner

Sorry for the delay. I'm hot off the plane and at the keyboard right now. Please follow #80.

@bholloway
Copy link
Owner

bholloway commented Mar 4, 2018

Thanks to @acoll the fix is now on master. If anyone is available please have a quick test of master before I publish.

npm i bholloway/resolve-url-loader

(unpublished but version is optimistically 2.3.0)

There are only minor changes to what was tested in #80 and should just work. I have checked a legacy Webpack 1 project and that is good but that is all I have to hand right now.

(My apologies I really need to get a good matrix of automated testing)

@alexdevero
Copy link

Thanks a lot @bholloway! I just tested it on one of my apps and the unpublished bholloway/resolve-url-loader works.

@cascornelissen
Copy link

The latest master version seems to work on my end as well (webpack 4) 👍

@bholloway
Copy link
Owner

Thanks @alexdevero @cascornelissen. Published as 2.3.0.

Please let me know any immediate problems here. Thanks for the contribution to this issue.

@julkue
Copy link

julkue commented Mar 4, 2018

@bholloway The release is not on GitHub, only on npm.

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

10 participants