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 4 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 中会丢失数组子元素的问题
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();
});
});
6 changes: 4 additions & 2 deletions packages/builder/builder/src/plugins/tsChecker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
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';

export const builderPluginTsChecker = (): DefaultBuilderPlugin => {
Expand Down Expand Up @@ -32,6 +31,9 @@ export const builderPluginTsChecker = (): DefaultBuilderPlugin => {
const { logger, CHAIN_ID, applyOptionsChain } = await import(
'@modern-js/utils'
);
const { mergeBuilderConfig } = await import(
'@modern-js/builder-shared'
);

// use typescript of user project
let typescriptPath: string;
Expand Down Expand Up @@ -86,7 +88,7 @@ export const builderPluginTsChecker = (): DefaultBuilderPlugin => {
},
config.tools.tsChecker,
undefined,
deepMerge,
mergeBuilderConfig,
chenjiahan marked this conversation as resolved.
Show resolved Hide resolved
);

if (
Expand Down
Loading