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

feat: support config functions with multi-compiler #5196

Merged
merged 1 commit into from Jul 6, 2017

Conversation

AndersDJohnson
Copy link
Contributor

What kind of change does this PR introduce?

feature

Did you add tests for your changes?

Yes, but let me know if inadequate.

If relevant, link to documentation update:

No documentation updates yet, but can provide. Arguably, the docs already imply that multiple functions are supported.

Summary

We already support configurations arrays for the multi-compiler, and configurations as functions in the singular case, but they don't seem to work together - until now.

Does this PR introduce a breaking change?

No.

Other information

Feel free to ask.

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

};

function handleFunction(options, argv) {
var isES6DefaultExportedFunc = (
Copy link
Member

Choose a reason for hiding this comment

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

the es6 default handling should be before the array handling.

test with

exports.default = [
  function() {
    return {};
  }
]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sokra Good catch. Updated and added test.

@@ -0,0 +1,22 @@
module.exports = function prepareOptions(options, argv) {
Copy link
Member

Choose a reason for hiding this comment

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

Write new files in ES6.

  • "use strict"
  • const/let
  • arrow function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sokra Thanks, I wasn't sure if non-ES6 was intentional. Updated, though still using functions for top-level rather than const + arrow - let me know if I should change. We should consider adding staged-only linting for this.

Copy link
Member

Choose a reason for hiding this comment

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

@AndersDJohnson What did you mean by the following:

We should consider adding staged-only linting for this.

Looking to add an issue for this so a contributor can pick it up (unless you would like to)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const optionsArr = [].concat(options);
let options = require(path.join(testDirectory, "webpack.config.js"));
options = prepareOptions(options);
let optionsArr = [].concat(options);
Copy link
Member

Choose a reason for hiding this comment

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

const x2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sokra Done by wrapping the require directly in a call to prepareOptions, if that's cool.

@webpack-bot
Copy link
Contributor

@AndersDJohnson Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@sokra sokra merged commit 0ab36c4 into webpack:master Jul 6, 2017
@sokra
Copy link
Member

sokra commented Jul 6, 2017

Thanks

@AndersDJohnson
Copy link
Contributor Author

Looks like we still need to support this for the programmatic API (i.e. webpack(options)).

@AndersDJohnson
Copy link
Contributor Author

Function support for the programmatic API proposed in #5585.

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.

None yet

4 participants