diff --git a/.changeset/wise-donuts-remain.md b/.changeset/wise-donuts-remain.md new file mode 100644 index 000000000000..e4242a268012 --- /dev/null +++ b/.changeset/wise-donuts-remain.md @@ -0,0 +1,7 @@ +--- +'@modern-js/builder-webpack-provider': patch +--- + +fix(builder): deep-merge lose array items under tools.tschecker + +fix(builder): 修复 deep-merge 在 tools.tschecker 中会丢失数组子元素的问题 diff --git a/packages/builder/builder-webpack-provider/package.json b/packages/builder/builder-webpack-provider/package.json index 216f29700933..b5a9ffd8c826 100644 --- a/packages/builder/builder-webpack-provider/package.json +++ b/packages/builder/builder-webpack-provider/package.json @@ -107,8 +107,8 @@ "react-refresh": "0.14.0", "style-loader": "3.3.3", "terser-webpack-plugin": "5.3.9", - "tsconfig-paths-webpack-plugin": "4.1.0", "ts-loader": "9.4.4", + "tsconfig-paths-webpack-plugin": "4.1.0", "webpack": "^5.88.1", "webpack-subresource-integrity": "5.1.0" }, @@ -120,9 +120,9 @@ "@types/caniuse-lite": "^1.0.1", "@types/node": "^14", "antd": "4", - "typescript": "^5", "react": "^18", - "react-dom": "^18" + "react-dom": "^18", + "typescript": "^5" }, "sideEffects": false, "publishConfig": { diff --git a/packages/builder/builder-webpack-provider/tests/plugins/__snapshots__/tsChecker.test.ts.snap b/packages/builder/builder-webpack-provider/tests/plugins/__snapshots__/tsChecker.test.ts.snap index 52c13110e9e4..fe377e3427f3 100644 --- a/packages/builder/builder-webpack-provider/tests/plugins/__snapshots__/tsChecker.test.ts.snap +++ b/packages/builder/builder-webpack-provider/tests/plugins/__snapshots__/tsChecker.test.ts.snap @@ -63,3 +63,36 @@ exports[`plugins/tsChecker > should only apply one tsChecker plugin when there i {}, ] `; + +exports[`plugins/tsChecker > should tschecker.issue.exclude final config merge correctly 1`] = ` +{ + "plugins": [ + ForkTsCheckerWebpackPlugin { + "options": { + "issue": { + "exclude": [ + { + "file": "**/*.(spec|test).ts", + }, + { + "file": "**/node_modules/**/*", + }, + { + "file": "src/**/*.ts", + }, + ], + }, + "logger": { + "error": [Function], + "log": [Function], + }, + "typescript": { + "configFile": "/path/tsconfig.json", + "memoryLimit": 8192, + "typescriptPath": "/node_modules//typescript/lib/typescript.js", + }, + }, + }, + ], +} +`; diff --git a/packages/builder/builder-webpack-provider/tests/plugins/tsChecker.test.ts b/packages/builder/builder-webpack-provider/tests/plugins/tsChecker.test.ts index 9d98009eafba..64a7462f01f7 100644 --- a/packages/builder/builder-webpack-provider/tests/plugins/tsChecker.test.ts +++ b/packages/builder/builder-webpack-provider/tests/plugins/tsChecker.test.ts @@ -80,4 +80,22 @@ describe('plugins/tsChecker', () => { const configs = await builder.unwrapWebpackConfigs(); expect(configs).toMatchSnapshot(); }); + + it('should tschecker.issue.exclude final config merge correctly', async () => { + const builder = await createStubBuilder({ + plugins: [builderPluginTsChecker()], + context, + builderConfig: { + tools: { + tsChecker: { + issue: { + exclude: [{ file: './src/**/*.ts' }], + }, + }, + }, + }, + }); + const config = await builder.unwrapWebpackConfig(); + expect(config).toMatchSnapshot(); + }); }); diff --git a/packages/builder/builder/package.json b/packages/builder/builder/package.json index 6c5b8561716d..a7e4432ee5da 100644 --- a/packages/builder/builder/package.json +++ b/packages/builder/builder/package.json @@ -65,11 +65,12 @@ "@rsbuild/monorepo-utils": "0.0.7", "@svgr/webpack": "8.0.1", "@swc/helpers": "0.5.1", + "deepmerge": "^4.3.1", "jiti": "^1.20.0" }, "devDependencies": { - "@modern-js/builder-webpack-provider": "workspace:*", "@modern-js/builder-rspack-provider": "workspace:*", + "@modern-js/builder-webpack-provider": "workspace:*", "@scripts/build": "workspace:*", "@scripts/vitest-config": "workspace:*", "@types/babel__core": "^7.20.0", diff --git a/packages/builder/builder/src/plugins/tsChecker.ts b/packages/builder/builder/src/plugins/tsChecker.ts index de81e76ee826..1564eebc7a19 100644 --- a/packages/builder/builder/src/plugins/tsChecker.ts +++ b/packages/builder/builder/src/plugins/tsChecker.ts @@ -1,6 +1,6 @@ import { DefaultBuilderPlugin } from '@modern-js/builder-shared'; -import { merge as deepMerge } from '@modern-js/utils/lodash'; import type { BuilderPluginAPI as WebpackBuilderPluginAPI } from '@modern-js/builder-webpack-provider'; +import deepmerge from 'deepmerge'; export const builderPluginTsChecker = (): DefaultBuilderPlugin => { return { @@ -86,7 +86,7 @@ export const builderPluginTsChecker = (): DefaultBuilderPlugin => { }, config.tools.tsChecker, undefined, - deepMerge, + deepmerge, ); if (