From 5ff10697d9409933067471b756a36d86e79b28cf Mon Sep 17 00:00:00 2001 From: Mateo Tibaquira Date: Wed, 10 Apr 2024 00:25:20 -0500 Subject: [PATCH 1/2] fix(webpack): fix default compiler option given a configuration without tsConfig the babel compiler breaks applying Nx dependent config --- .../src/plugins/nx-webpack-plugin/lib/apply-base-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.ts b/packages/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.ts index 88cbebc5a460b..0d8e5469c55a7 100644 --- a/packages/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.ts +++ b/packages/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.ts @@ -41,7 +41,7 @@ export function applyBaseConfig( } = {} ): void { // Defaults that was applied from executor schema previously. - options.compiler ??= 'babel'; + options.compiler ??= options.tsConfig ? 'babel' : undefined; options.deleteOutputPath ??= true; options.externalDependencies ??= 'all'; options.fileReplacements ??= []; From b33ac0dabfa6b9592191b5f3adf39d0b579157b3 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Wed, 8 May 2024 12:28:44 +0100 Subject: [PATCH 2/2] fix(webpack): only read tsconfig if path to it exists --- .../plugins/nx-webpack-plugin/lib/apply-base-config.ts | 2 +- .../src/plugins/nx-webpack-plugin/lib/compiler-loaders.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.ts b/packages/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.ts index 0d8e5469c55a7..88cbebc5a460b 100644 --- a/packages/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.ts +++ b/packages/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.ts @@ -41,7 +41,7 @@ export function applyBaseConfig( } = {} ): void { // Defaults that was applied from executor schema previously. - options.compiler ??= options.tsConfig ? 'babel' : undefined; + options.compiler ??= 'babel'; options.deleteOutputPath ??= true; options.externalDependencies ??= 'all'; options.fileReplacements ??= []; diff --git a/packages/webpack/src/plugins/nx-webpack-plugin/lib/compiler-loaders.ts b/packages/webpack/src/plugins/nx-webpack-plugin/lib/compiler-loaders.ts index de2b3267cb504..e17085663e095 100644 --- a/packages/webpack/src/plugins/nx-webpack-plugin/lib/compiler-loaders.ts +++ b/packages/webpack/src/plugins/nx-webpack-plugin/lib/compiler-loaders.ts @@ -54,7 +54,9 @@ export function createLoaderFromCompiler( }, }; case 'babel': - const tsConfig = readTsConfig(path.join(options.root, options.tsConfig)); + const tsConfig = options.tsConfig + ? readTsConfig(path.join(options.root, options.tsConfig)) + : undefined; const babelConfig = { test: /\.([jt])sx?$/, @@ -62,7 +64,9 @@ export function createLoaderFromCompiler( exclude: /node_modules/, options: { cwd: path.join(options.root, options.sourceRoot), - emitDecoratorMetadata: tsConfig.options.emitDecoratorMetadata, + emitDecoratorMetadata: tsConfig + ? tsConfig.options.emitDecoratorMetadata + : false, isModern: true, isTest: process.env.NX_CYPRESS_COMPONENT_TEST === 'true', envName: process.env.BABEL_ENV ?? process.env.NODE_ENV,