Skip to content

fix: check webpack installation before running cli#1827

Merged
snitin315 merged 8 commits intonextfrom
fix/check-webpack-installation
Sep 25, 2020
Merged

fix: check webpack installation before running cli#1827
snitin315 merged 8 commits intonextfrom
fix/check-webpack-installation

Conversation

@snitin315
Copy link
Copy Markdown
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

@snitin315 snitin315 requested a review from a team as a code owner September 24, 2020 08:45
let cli = undefined;
if (packageExists('webpack')) {
cli = require('webpack').cli;
}
Copy link
Copy Markdown
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
Copy Markdown
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'

const importLocal = require('import-local');
const runCLI = require('../lib/bootstrap');
const { yellow } = require('colorette');
const { packageExists, promptInstallation } = require('@webpack-cli/package-utils');
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

@snitin315 snitin315 force-pushed the fix/check-webpack-installation branch from 8471606 to 36e75ab Compare September 25, 2020 06:30
@snitin315 snitin315 force-pushed the fix/check-webpack-installation branch from 36e75ab to eecd833 Compare September 25, 2020 06:33
@webpack-bot
Copy link
Copy Markdown

@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