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: improve check for custom webpack-dev-server package existance #3772

Merged
merged 3 commits into from Jun 4, 2023

Conversation

snitin315
Copy link
Member

What kind of change does this PR introduce?
bugfix

Did you add tests for your changes?
No
If relevant, did you update the documentation?
No
Summary

Fix #3161

Does this PR introduce a breaking change?
No

Other information
No

@snitin315 snitin315 requested a review from a team as a code owner May 6, 2023 02:46
Comment on lines 529 to 576
if (
dependency === WEBPACK_DEV_SERVER_PACKAGE &&
fs.existsSync(WEBPACK_DEV_SERVER_PACKAGE)
) {
skipInstallation = true;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

The current behavior is to check for the package and if it doesn't exist we ask users to install it.

Screenshot 2023-05-06 at 8 17 12 AM

If we use require.resolve() it will throw an error and exit the process. Should we use it?

Copy link
Member

Choose a reason for hiding this comment

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

Good question, and another good question why we used fs.existsSync here, can you look at git history?

Copy link
Member Author

@snitin315 snitin315 May 8, 2023

Choose a reason for hiding this comment

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

@alexander-akait added in this PR #2907

Copy link
Member

Choose a reason for hiding this comment

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

@snitin315 I think we can remove this check, if developer provided a bad path, node.js itself generate a good error, so I think it is extra unnecessary check

Copy link
Member

Choose a reason for hiding this comment

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

Not sure why I was added it 😄

@codecov
Copy link

codecov bot commented May 6, 2023

Codecov Report

Merging #3772 (f440ac3) into master (fa0553c) will decrease coverage by 0.03%.
The diff coverage is 90.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3772      +/-   ##
==========================================
- Coverage   91.42%   91.39%   -0.03%     
==========================================
  Files          22       22              
  Lines        1667     1673       +6     
  Branches      480      484       +4     
==========================================
+ Hits         1524     1529       +5     
- Misses        143      144       +1     
Impacted Files Coverage Δ
packages/webpack-cli/src/webpack-cli.ts 92.60% <90.00%> (-0.06%) ⬇️

Continue to review full report in Codecov by Sentry.

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

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Looks good, let's add a small test case where we have invalid/unknown path to webpack and/or webpack-dev-server, just ensure we throw an error and it is readable

@alexander-akait alexander-akait merged commit 0931ab6 into master Jun 4, 2023
53 of 55 checks passed
@alexander-akait alexander-akait deleted the fix/webpack-check branch June 4, 2023 00:52
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

3 participants