Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

fix(index): add this.rootContext #234

Conversation

TheLarkInn
Copy link

@TheLarkInn TheLarkInn commented Dec 5, 2017

Notable Changes

  • Adds this.rootContext (webpack >= v4.0.0) for compatibility with webpack v4.0.0

Issues

@joshwiens joshwiens changed the title feat(context): Update context to rootContext refactor(context): Update context to rootContext Dec 5, 2017
@michael-ciniawsky michael-ciniawsky added this to the 2.0.0 milestone Dec 5, 2017
@michael-ciniawsky michael-ciniawsky changed the title refactor(context): Update context to rootContext refactor(index): update this.context to this.rootContext Dec 5, 2017
src/index.js Outdated
@@ -10,7 +10,7 @@ export default function loader(content) {

validateOptions(schema, options, 'File Loader');

const context = options.context || this.options.context;
const context = this.rootContext;
Copy link
Member

@michael-ciniawsky michael-ciniawsky Dec 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the option for a setting a custom context be removed on purpose?
Doesn't this work anymore in general now ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is breaking for anything that needs is much like we had to do for etwp 3.1

For any loaders & plugins that require this change, make sure the next branch has the peerDependency set to 4.x only

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So a options.context can't technically exists anymore with the changes made to the underlying logic in webpack (rootContext) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const context = options.context || this.rootContext || this.options && this.options.context

this.options doesn't exist anymore. It was already deprecated in webpack 3. webpack 4 adds this.rootContext as replacement for the needed context information. We could backport this if it helps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there particular reason to name it rootContext instead of context ? :) I assumed the meaning/logic also changed somehow due to the rename and the correlation between config.context => this.context is cleaner. There is also no e.g childContext etc, or is there anything new ?

👍 for a backport of rootContext to webpack v3.0.0 so loaders/plugins relying on it don't need to add legacy code checks

@TheLarkInn Could you update the PR with @sokra suggestions so we can release a patch instead of a major for this/for now, so folks can continue trying out more advanced stuff (changes) in the meantime ? 😛 (Fairly depressing to fail at the file-loader 🙃...)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incoming

@michael-ciniawsky
Copy link
Member

@TheLarkInn Can I take this over or could you apply these changes

- const context = this.rootContext
+ const context = options.context || this.rootContext || this.options && this.options.context

and rebase please ?

@michael-ciniawsky michael-ciniawsky changed the base branch from next to master December 15, 2017 14:15
@michael-ciniawsky michael-ciniawsky changed the title refactor(index): update this.context to this.rootContext fix(index): add this.rootContext Dec 15, 2017
@michael-ciniawsky michael-ciniawsky modified the milestones: 2.0.0, 1.1.5 Dec 15, 2017
@TheLarkInn TheLarkInn changed the base branch from master to next December 16, 2017 05:58
@joshwiens joshwiens closed this Dec 16, 2017
@joshwiens
Copy link
Member

Closing this because someone needs to take a git class .....

@michael-ciniawsky
Copy link
Member

The fix should go into master please, so webpack v3.0.0 && 4.0.0 is supported by the file-loader =< v1.0.0 for next we just use const context = options.context || this.rootContext then and remove all the legacy stuff. The fix is easy and I need this for html-loader, style-loader, css-loader, ETWP e2e testing 😛

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

Successfully merging this pull request may close these issues.

4 participants