Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(builder): deep-merge lose array items under tools.tschecker #4804

Merged
merged 5 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.