Skip to content

Commit

Permalink
fix(builder): deep-merge lose array items under tools.tschecker (#4804)
Browse files Browse the repository at this point in the history
  • Loading branch information
fireairforce authored and 9aoy committed Oct 23, 2023
1 parent 45516ba commit 540164e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .changeset/wise-donuts-remain.md
Original file line number Diff line number Diff line change
@@ -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 中会丢失数组子元素的问题
6 changes: 3 additions & 3 deletions packages/builder/builder-webpack-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<WORKSPACE>/node_modules/<PNPM_INNER>/typescript/lib/typescript.js",
},
},
},
],
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
3 changes: 2 additions & 1 deletion packages/builder/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/builder/builder/src/plugins/tsChecker.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -86,7 +86,7 @@ export const builderPluginTsChecker = (): DefaultBuilderPlugin => {
},
config.tools.tsChecker,
undefined,
deepMerge,
deepmerge,
);

if (
Expand Down

0 comments on commit 540164e

Please sign in to comment.