bholloway / resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file
563 stars 71 forks source link

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

Closed acoll closed 6 years ago

acoll commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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

About your comment, loaderUtils actually does that.

petrleocompel commented 6 years ago

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

bholloway commented 6 years ago

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.

julkue commented 6 years ago

I also have this issue

PR: https://github.com/julmot/form-components/pull/9 Build: https://travis-ci.org/julmot/form-components/builds/347651941?utm_source=github_status&utm_medium=notification

d2phap commented 6 years ago

I have the same issue after upgrading to Webpack 4

julkue commented 6 years ago

@bholloway What's the status?

hadnet commented 6 years ago

Same thing here. Any news?

dmaicher commented 6 years ago

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 commented 6 years ago

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

bholloway commented 6 years ago

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 commented 6 years ago

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

cascornelissen commented 6 years ago

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

bholloway commented 6 years ago

Thanks @alexdevero @cascornelissen. Published as 2.3.0.

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

julkue commented 6 years ago

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