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: support top multi compiler options #2874

Merged
merged 3 commits into from Aug 5, 2021
Merged

fix: support top multi compiler options #2874

merged 3 commits into from Aug 5, 2021

Conversation

alexander-akait
Copy link
Member

@alexander-akait alexander-akait commented Aug 3, 2021

What kind of change does this PR introduce?

bugfix

Did you add tests for your changes?

yes

If relevant, did you update the documentation?

No

Summary

fixes #2873

Does this PR introduce a breaking change?

No

Other information

We should refactor our logic for multiple --config, ideally I think we should run merge when multiple configurations provided, but it is breaking change and should be solved for the next major release

const evaluatedConfigs = await Promise.all(
options.config.map(async (value) =>
evaluateConfig(await loadConfig(path.resolve(value)), options.argv || {}),
const loadedConfig = await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const loadedConfig = await Promise.all(
const loadedConfigs = await Promise.all(

loadedConfig.forEach((loadedConfig) => {
const isArray = Array.isArray(loadedConfig.options);

// TODO we should run webpack multiple times when the `--config` options has multiple values without `--merge`, need to solve for the next major release
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// TODO we should run webpack multiple times when the `--config` options has multiple values without `--merge`, need to solve for the next major release
// TODO we should run webpack multiple times when the `--config` options have multiple values with `--merge`, need to solve for the next major release

evaluatedConfig.options.forEach((options) => {
config.options.push(options);
config.path.set(options, evaluatedConfig.path);
loadedConfig.forEach((loadedConfig) => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
loadedConfig.forEach((loadedConfig) => {
loadedConfigs.forEach((loadedConfig) => {

@codecov
Copy link

codecov bot commented Aug 4, 2021

Codecov Report

Merging #2874 (82ad0bb) into master (26d4ba0) will decrease coverage by 0.06%.
The diff coverage is 97.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2874      +/-   ##
==========================================
- Coverage   95.01%   94.95%   -0.07%     
==========================================
  Files          31       31              
  Lines        1706     1704       -2     
  Branches      498      484      -14     
==========================================
- Hits         1621     1618       -3     
- Misses         85       86       +1     
Impacted Files Coverage Δ
packages/webpack-cli/lib/webpack-cli.js 96.76% <97.59%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 26d4ba0...82ad0bb. Read the comment docs.

@alexander-akait
Copy link
Member Author

/cc @webpack/cli-team need review

Copy link
Member

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

LGTM

async loadConfig(configPath, argv = {}) {
const { interpret } = this.utils;
const ext = path.extname(configPath);
const interpreted = Object.keys(interpret.jsVariants).find((variant) => variant === ext);
Copy link
Member

Choose a reason for hiding this comment

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

can just use interpret.jsVariants[ext] ?

Copy link
Member

Choose a reason for hiding this comment

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

oh it is existing logic, maybe we can improve it late

@alexander-akait alexander-akait merged commit 82b1fb7 into master Aug 5, 2021
@alexander-akait alexander-akait deleted the issue-2873 branch August 5, 2021 16:57
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.

parallelism not work
4 participants