From 1b7cd9b86f0e0cf9287b3524b03aed2059bbecf9 Mon Sep 17 00:00:00 2001 From: Nicholas Cunningham Date: Fri, 15 Nov 2024 08:57:10 -0700 Subject: [PATCH] fix(webpack): sourceMap type should accept all types of sourceMaps (#28947) --- packages/rspack/src/executors/rspack/schema.d.ts | 4 ++-- packages/rspack/src/plugins/utils/apply-base-config.ts | 7 ++----- packages/rspack/src/plugins/utils/models.ts | 4 ++-- packages/webpack/src/executors/webpack/schema.d.ts | 2 +- .../src/plugins/nx-webpack-plugin/lib/apply-base-config.ts | 6 +----- .../nx-webpack-plugin/nx-app-webpack-plugin-options.ts | 2 +- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/rspack/src/executors/rspack/schema.d.ts b/packages/rspack/src/executors/rspack/schema.d.ts index dfbff63a98e48..10dcd8c545123 100644 --- a/packages/rspack/src/executors/rspack/schema.d.ts +++ b/packages/rspack/src/executors/rspack/schema.d.ts @@ -1,4 +1,4 @@ -import type { Mode } from '@rspack/core'; +import type { DevTool, Mode } from '@rspack/core'; export interface RspackExecutorSchema { additionalEntryPoints?: AdditionalEntryPoint[]; @@ -32,7 +32,7 @@ export interface RspackExecutorSchema { runtimeChunk?: boolean; scripts?: Array; skipTypeChecking?: boolean; - sourceMap?: boolean | string; + sourceMap?: boolean | DevTool; standardRspackConfigFunction?: boolean; statsJson?: boolean; stylePreprocessorOptions?: any; diff --git a/packages/rspack/src/plugins/utils/apply-base-config.ts b/packages/rspack/src/plugins/utils/apply-base-config.ts index 6e309ccc7b41c..33139b417c78f 100644 --- a/packages/rspack/src/plugins/utils/apply-base-config.ts +++ b/packages/rspack/src/plugins/utils/apply-base-config.ts @@ -8,6 +8,7 @@ import { SwcJsMinimizerRspackPlugin, CopyRspackPlugin, RspackOptionsNormalized, + type DevTool, } from '@rspack/core'; import { getRootTsConfigPath } from '@nx/js'; @@ -87,11 +88,7 @@ function applyNxIndependentConfig( config.cache = options.target === 'node' && options.watch ? true : undefined; config.devtool = - options.sourceMap === 'hidden' - ? 'hidden-source-map' - : options.sourceMap - ? 'source-map' - : false; + options.sourceMap === true ? 'source-map' : options.sourceMap; config.output = { ...(config.output ?? {}), diff --git a/packages/rspack/src/plugins/utils/models.ts b/packages/rspack/src/plugins/utils/models.ts index 925da59b047e7..82455ce8fdbea 100644 --- a/packages/rspack/src/plugins/utils/models.ts +++ b/packages/rspack/src/plugins/utils/models.ts @@ -1,4 +1,4 @@ -import type { Mode } from '@rspack/core'; +import type { DevTool, Mode } from '@rspack/core'; import type { ProjectGraph } from '@nx/devkit'; import type { AssetGlob } from '@nx/js/src/utils/assets/assets'; @@ -182,7 +182,7 @@ export interface NxAppRspackPluginOptions { /** * Generate source maps. */ - sourceMap?: boolean | string; + sourceMap?: boolean | DevTool; /** * When `true`, `process.env.NODE_ENV` will be excluded from the bundle. Useful for building a web application to run in a Node environment. */ diff --git a/packages/webpack/src/executors/webpack/schema.d.ts b/packages/webpack/src/executors/webpack/schema.d.ts index 610e76f5c544e..883e4d91ca9d5 100644 --- a/packages/webpack/src/executors/webpack/schema.d.ts +++ b/packages/webpack/src/executors/webpack/schema.d.ts @@ -62,7 +62,7 @@ export interface WebpackExecutorOptions { polyfills?: string; progress?: boolean; runtimeChunk?: boolean; - sourceMap?: boolean | 'hidden'; + sourceMap?: boolean | string; statsJson?: boolean; target?: string; transformers?: TransformerEntry[]; 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 1f84310786085..751435ecdad29 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 @@ -86,11 +86,7 @@ function applyNxIndependentConfig( options.target === 'node' && options.watch ? { type: 'memory' } : undefined; config.devtool = - options.sourceMap === 'hidden' - ? 'hidden-source-map' - : options.sourceMap - ? 'source-map' - : false; + options.sourceMap === true ? 'source-map' : options.sourceMap; config.output = { ...config.output, diff --git a/packages/webpack/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.ts b/packages/webpack/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.ts index 2adde5f110ff0..fac494d3ff5c6 100644 --- a/packages/webpack/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.ts +++ b/packages/webpack/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.ts @@ -182,7 +182,7 @@ export interface NxAppWebpackPluginOptions { /** * Generate source maps. */ - sourceMap?: boolean | 'hidden'; + sourceMap?: boolean | string; /** * When `true`, `process.env.NODE_ENV` will be excluded from the bundle. Useful for building a web application to run in a Node environment. */