webpack-cli icon indicating copy to clipboard operation
webpack-cli copied to clipboard

fix: attempts custom package require without path exists check

Open solsson opened this issue 2 years ago • 7 comments

What kind of change does this PR introduce?

Bugfix

Did you add tests for your changes?

No

If relevant, did you update the documentation?

Yes

Summary

Firstly this change fixes an issue that looks like a copy-paste error: Custom WEBPACK_DEV_SERVER_PACKAGE would be conditioned on WEBPACK_PACKAGE to exist.

The next change, using require.resolve, widens the usefulness of the override. With plain existsSync you basically need an absolute path, unless you know what the current working directory will be when using the override.

Does this PR introduce a breaking change?

I don't think so. Existing WEBPACK_PACKAGE or WEBPACK_DEV_SERVER_PACKAGE would have satisfied fs.existsSync(require.resolve(path))) if they worked.

Other information

solsson avatar Mar 13 '22 13:03 solsson

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: solsson (440dfb97cd799081eaf6caba883c8982884ce817, fc9797e66b337f6cd776115c9960c2674e968196, e86416e583fd32b801fa5cbeceef4628016d7fbb)

Thanks, can you accept CLA?

alexander-akait avatar Mar 13 '22 13:03 alexander-akait

CLA signed.

Actually if the existsSync check causes any issues I'd be in favor of dropping it. These envs have distinct names that are unlikely to collide with other use of evns. Silently dropping them might cause more confusion than attempting the require regardless of value.

solsson avatar Mar 13 '22 13:03 solsson

I will force push to only the first commit, then get one commit at a time through CI.

solsson avatar Mar 13 '22 15:03 solsson

Codecov Report

Merging #3161 (7a83488) into master (af820d2) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3161   +/-   ##
=======================================
  Coverage   91.44%   91.45%           
=======================================
  Files          23       23           
  Lines        1719     1721    +2     
  Branches      519      519           
=======================================
+ Hits         1572     1574    +2     
  Misses        147      147           
Impacted Files Coverage Δ
packages/webpack-cli/src/webpack-cli.ts 93.96% <100.00%> (+0.01%) :arrow_up:

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 af820d2...7a83488. Read the comment docs.

codecov[bot] avatar Mar 13 '22 15:03 codecov[bot]

@solsson can you fix lint?

snitin315 avatar Mar 14 '22 00:03 snitin315

@solsson Thanks for your update.

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

@rishabh3112 Please review the new changes.

webpack-bot avatar Mar 14 '22 06:03 webpack-bot

@solsson Hello, do you have time to finish this PR? Because it is easy to fix lint, thank you

alexander-akait avatar Apr 29 '23 19:04 alexander-akait