Skip to content

Commit da9e146

Browse files
Safeguard bundle option check (#3256) (#3262)
In case the project does not have dependencies or dev-dependencies CLI should fail with correct message when `--bundle` is passed.
1 parent 013ed91 commit da9e146

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/commands/base-bundler.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export abstract class BundleBase {
1212
protected validateBundling(): void {
1313
if (this.$options.bundle) {
1414
const bundlePluginName = this.bundlersMap[this.$options.bundle];
15-
if (!bundlePluginName || (!this.$projectData.devDependencies[bundlePluginName] && !this.$projectData.dependencies[bundlePluginName])) {
15+
const hasBundlerPluginAsDependency = this.$projectData.dependencies && this.$projectData.dependencies[bundlePluginName];
16+
const hasBundlerPluginAsDevDependency = this.$projectData.devDependencies && this.$projectData.devDependencies[bundlePluginName];
17+
if (!bundlePluginName || (!hasBundlerPluginAsDependency && !hasBundlerPluginAsDevDependency)) {
1618
this.$errors.fail("Passing --bundle requires a bundling plugin. No bundling plugin found or the specified bundling plugin is invalid.");
1719
}
1820
}

0 commit comments

Comments
 (0)