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: check webpack installation before running cli #1827

Merged
merged 8 commits into from Sep 25, 2020

Conversation

snitin315
Copy link
Member

What kind of change does this PR introduce?
fix

Did you add tests for your changes?
no
If relevant, did you update the documentation?
no
Summary
prompt to install webpack if it's not present already.

Screenshot at 2020-09-24 13-55-05

Does this PR introduce a breaking change?
No

Other information
Refers #1383 (comment)
Fixes #1383

let cli = undefined;
if (packageExists('webpack')) {
cli = require('webpack').cli;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can be refactored as -> const cli = packageExists('webpack') ? require('webpack').cli : undefined

Else we get Error: can't find module 'webpack'

@@ -4,13 +4,21 @@
require('v8-compile-cache');
const importLocal = require('import-local');
const runCLI = require('../lib/bootstrap');
const { yellow } = require('colorette');
const { packageExists, promptInstallation } = require('@webpack-cli/package-utils');
Copy link
Member

Choose a reason for hiding this comment

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

Do we add package-utils in deps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes Already present.

"@webpack-cli/package-utils": "^1.0.1-rc.0",

Copy link
Member Author

Choose a reason for hiding this comment

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

But these utils are only being used by webpack-cli, So we can safely move it from package-utils to utils. Let's do this in separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

#1822 will solve this

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.

Good idea!

@webpack-bot
Copy link

@snitin315 Thanks for your update.

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

@rishabh3112 Please review the new changes.

@snitin315 snitin315 merged commit be509fa into next Sep 25, 2020
@snitin315 snitin315 deleted the fix/check-webpack-installation branch September 25, 2020 14:13
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.

Interesting behavior when using info as a value for --info-verbosity
7 participants