Skip to content

Commit 5b4384e

Browse files
authored
feat: support dts.abortOnError (#69)
1 parent 89cb72a commit 5b4384e

File tree

13 files changed

+147
-11
lines changed

13 files changed

+147
-11
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleEsmConfig(__dirname, {
7+
bundle: false,
8+
dts: {
9+
bundle: false,
10+
distPath: './dist/error',
11+
abortOnError: false,
12+
},
13+
}),
14+
generateBundleCjsConfig(__dirname, {
15+
bundle: false,
16+
}),
17+
],
18+
source: {
19+
entry: {
20+
main: ['./src-error/**'],
21+
},
22+
tsconfigPath: 'tsconfig-error.json',
23+
},
24+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface A {
2+
a: number;
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { A } from './const';
2+
3+
export const getA = (item: A) => {
4+
item.a = '0';
5+
return item;
6+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "@rslib/tsconfig/base",
3+
"compilerOptions": {
4+
"baseUrl": "./",
5+
"rootDir": "src-error"
6+
},
7+
"include": ["src-error"]
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleEsmConfig(__dirname, {
7+
dts: {
8+
bundle: true,
9+
distPath: './dist/error',
10+
abortOnError: false,
11+
},
12+
}),
13+
generateBundleCjsConfig(__dirname),
14+
],
15+
source: {
16+
entry: {
17+
main: './src-error/index.ts',
18+
},
19+
tsconfigPath: 'tsconfig-error.json',
20+
},
21+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface A {
2+
a: number;
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { A } from './const';
2+
3+
export const getA = (item: A) => {
4+
item.a = '0';
5+
return item;
6+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "@rslib/tsconfig/base",
3+
"compilerOptions": {
4+
"baseUrl": "./",
5+
"rootDir": "src-error"
6+
},
7+
"include": ["src-error"]
8+
}

e2e/cases/dts/index.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ describe('dts when bundle: false', () => {
3737
expect(files.esm?.length).toBe(4);
3838
expect(files.esm?.[0]!.startsWith('./dist/custom')).toEqual(true);
3939
});
40+
41+
test('abortOnError: false', async () => {
42+
const fixturePath = join(__dirname, 'bundle-false');
43+
const { isSuccess } = await buildAndGetResults(
44+
fixturePath,
45+
'abortOnError.config.ts',
46+
'dts',
47+
);
48+
49+
expect(isSuccess).toBe(true);
50+
});
4051
});
4152

4253
describe('dts when bundle: true', () => {
@@ -73,4 +84,15 @@ describe('dts when bundle: true', () => {
7384

7485
expect(entryFiles.esm!.startsWith('./dist/custom')).toEqual(true);
7586
});
87+
88+
test('abortOnError: false', async () => {
89+
const fixturePath = join(__dirname, 'bundle');
90+
const { isSuccess } = await buildAndGetResults(
91+
fixturePath,
92+
'abortOnError.config.ts',
93+
'dts',
94+
);
95+
96+
expect(isSuccess).toBe(true);
97+
});
7698
});

e2e/scripts/shared.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export const buildAndGetResults = async (
113113
entryFiles: Record<string, string>;
114114
rspackConfig: InspectConfigResult['origin']['bundlerConfigs'];
115115
rsbuildConfig: InspectConfigResult['origin']['rsbuildConfig'];
116+
isSuccess: boolean;
116117
}> => {
117118
const rslibConfig = await loadConfig(join(fixturePath, configFile));
118119
process.chdir(fixturePath);
@@ -129,5 +130,6 @@ export const buildAndGetResults = async (
129130
entryFiles: results.entryFiles,
130131
rspackConfig: bundlerConfigs,
131132
rsbuildConfig: rsbuildConfig,
133+
isSuccess: Boolean(rsbuildInstance),
132134
};
133135
};

0 commit comments

Comments
 (0)