From 4aa90bb2a2a30c6df4a8bf3b418fcefbefa3a44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Tue, 1 Oct 2024 15:09:36 +0200 Subject: [PATCH] fix(js): throw an error when generating a publishable lib with `--bundler=none` --- packages/js/src/generators/library/library.ts | 4 +++- packages/nest/src/generators/library/lib/normalize-options.ts | 2 +- packages/node/src/generators/library/library.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/js/src/generators/library/library.ts b/packages/js/src/generators/library/library.ts index 26a6d99ee5716..4e57aca4c53ee 100644 --- a/packages/js/src/generators/library/library.ts +++ b/packages/js/src/generators/library/library.ts @@ -839,7 +839,9 @@ async function normalizeOptions( } if (options.bundler === 'none') { - options.bundler = 'tsc'; + throw new Error( + `Publishable libraries can't be generated with "--bundler=none". Please select a valid bundler.` + ); } } diff --git a/packages/nest/src/generators/library/lib/normalize-options.ts b/packages/nest/src/generators/library/lib/normalize-options.ts index 5f15e9c8fbec9..5048501de7b61 100644 --- a/packages/nest/src/generators/library/lib/normalize-options.ts +++ b/packages/nest/src/generators/library/lib/normalize-options.ts @@ -61,7 +61,7 @@ export function toJsLibraryGeneratorOptions( ): JsLibraryGeneratorSchema { return { name: options.name, - bundler: options?.buildable ? 'tsc' : 'none', + bundler: options.buildable || options.publishable ? 'tsc' : 'none', directory: options.directory, importPath: options.importPath, linter: options.linter, diff --git a/packages/node/src/generators/library/library.ts b/packages/node/src/generators/library/library.ts index 40ffc95c9fc29..8b47782b9a11c 100644 --- a/packages/node/src/generators/library/library.ts +++ b/packages/node/src/generators/library/library.ts @@ -56,7 +56,7 @@ export async function libraryGeneratorInternal(tree: Tree, schema: Schema) { const libraryInstall = await jsLibraryGenerator(tree, { ...options, - bundler: schema.buildable ? 'tsc' : 'none', + bundler: schema.buildable || schema.publishable ? 'tsc' : 'none', includeBabelRc: schema.babelJest, importPath: options.importPath, testEnvironment: 'node',