Closed acoll closed 6 years ago
@acoll This is something that was removed in webpack 4
this.options
andthis.rootContext
webpack 3 already deprecatedthis.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
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.
Unfortunately, there are no specific anchors, but it's in the release notes of webpack 4.
About your comment, loaderUtils
actually does that.
Now when webpack 4.0.0 was released.
See also Breaking changes for plugins/loaders
on release page.
Thanks everyone.
Unfortunately I’m AFK for another week. Sorry I didn’t anticipate this.
Let me see what I can do to get the fix published in the meantime.
I have the same issue after upgrading to Webpack 4
@bholloway What's the status?
Same thing here. Any news?
I'm using this fix temporarily:
https://github.com/dmaicher/resolve-url-loader/commit/1e9d6f046e7efb80988a3f8b4da89067036d6127
"resolve-url-loader": "github:dmaicher/resolve-url-loader#1e9d6f046e7efb80988a3f8b4da89067036d6127"
Sorry for the delay. I'm hot off the plane and at the keyboard right now. Please follow #80.
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)
Thanks a lot @bholloway! I just tested it on one of my apps and the unpublished bholloway/resolve-url-loader
works.
The latest master
version seems to work on my end as well (webpack 4) 👍
Thanks @alexdevero @cascornelissen. Published as 2.3.0
.
Please let me know any immediate problems here. Thanks for the contribution to this issue.
@bholloway The release is not on GitHub, only on npm.
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.