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

fix(mocha-env-loader): add webpack >= v4.0.0 support #341

Merged
merged 2 commits into from
Sep 1, 2018
Merged

fix(mocha-env-loader): add webpack >= v4.0.0 support #341

merged 2 commits into from
Sep 1, 2018

Conversation

ryanclark
Copy link
Collaborator

@ryanclark ryanclark commented Sep 1, 2018

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently the loader uses this.options, which is deprecated in webpack 4, causing an error.

What is the new behavior?

Adds the compilation name to the loader options and uses loader-utils to parse the loader context and retrieve the name.

Drops webpack < v4.0.0 support as it doesn't work due to webpack-dev-middleware not supporting anything less than v4.0.0.

Does this PR introduce a breaking change?

  • Yes
  • No

@@ -242,7 +242,7 @@ Plugin.prototype.make = function(compilation, callback) {
var entry = file

if (this.wrapMocha) {
entry = `${require.resolve('./mocha-env-loader')}!${entry}`
entry = `${require.resolve('./mocha-env-loader')}?name=${compilation.name}!${entry}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be potentially breaking ? It's fine since v4.0.0 is a beta release, but we need to be aware just in case :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've just tested it out and this will need to drop support for anything less than webpack 4 as it turns out webpack-dev-middleware has.

This comment was marked as resolved.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated peerDependencies, yeah [email protected] doesn't work with webpack < v4.0.0.

@@ -7,8 +7,10 @@ var SourceMapConsumer = sourceMap.SourceMapConsumer
module.exports = function(content, map) {
this.cacheable()

var options = loaderUtils.getOptions(this)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to always clone them

var options = Object.assign({}, loaderUtils.getOptions(this))

var sourceNode
var id = this.options.name
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@michael-ciniawsky michael-ciniawsky changed the title fix(mocha-env-loader): add webpack 4 support to mocha-env-loader fix(mocha-env-loader): add webpack >= v4.0.0 support Sep 1, 2018
@michael-ciniawsky michael-ciniawsky added this to the 4.0.0 milestone Sep 1, 2018
@ryanclark ryanclark changed the title fix(mocha-env-loader): add webpack >= v4.0.0 support fix(mocha-env-loader): add webpack >= v4.0.0 support, drop webpack < v4.0.0 Sep 1, 2018
@michael-ciniawsky michael-ciniawsky changed the title fix(mocha-env-loader): add webpack >= v4.0.0 support, drop webpack < v4.0.0 fix(mocha-env-loader): add webpack >= v4.0.0 support Sep 1, 2018
@michael-ciniawsky
Copy link
Contributor

michael-ciniawsky commented Sep 1, 2018

https://github.com/webpack-contrib/karma-webpack/releases/tag/v4.0.0-beta.0 already droppedwebpack < v4.0.0, this PR is semver patch :)

@michael-ciniawsky michael-ciniawsky changed the title fix(mocha-env-loader): add webpack >= v4.0.0 support fix(mocha-env-loader): add webpack >= v4.0.0 support, drop webpack < v4.0.0 Sep 1, 2018
@michael-ciniawsky michael-ciniawsky changed the title fix(mocha-env-loader): add webpack >= v4.0.0 support, drop webpack < v4.0.0 fix(mocha-env-loader): add webpack >= v4.0.0 support Sep 1, 2018
Copy link
Contributor

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

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

👍

@michael-ciniawsky
Copy link
Contributor

Released in v4.0.0-rc.0 🎉

@scipper
Copy link

scipper commented Sep 11, 2018

finally helpful error messages on failing execution! 🙌 I was searching for hours why my typescripts tests are not executed when I import certain modules. Now I now: I have to put them in the files array! Thanks folks! 😍

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

Successfully merging this pull request may close these issues.

3 participants