Skip to content

Commit fdffdcf

Browse files
committed
chore: update
1 parent a5c50b8 commit fdffdcf

File tree

10 files changed

+121
-0
lines changed

10 files changed

+121
-0
lines changed

pnpm-lock.yaml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "dts-build-auto-extension-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig } from '@rslib/core';
2+
import { generateBundleCjsConfig } from 'test-helper';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleCjsConfig({
7+
bundle: false,
8+
dts: {
9+
autoExtension: true,
10+
distPath: './dist/types',
11+
bundle: false,
12+
build: true,
13+
},
14+
}),
15+
],
16+
source: {
17+
entry: {
18+
index: ['./src/**'],
19+
},
20+
},
21+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './sum';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const num1 = 1;
2+
export const num2 = 2;
3+
export const num3 = 3;
4+
5+
export const str1 = 'str1';
6+
export const str2 = 'str2';
7+
export const str3 = 'str3';
8+
9+
export const numSum = num1 + num2 + num3;
10+
export const strSum = str1 + str2 + str3;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "@rslib/tsconfig/base",
3+
"compilerOptions": {
4+
"baseUrl": "./",
5+
"rootDir": "src",
6+
"declaration": true,
7+
"declarationDir": "./dist/types"
8+
},
9+
"include": ["src"],
10+
"references": [
11+
{
12+
"path": "../__references__"
13+
}
14+
]
15+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "dts-composite-auto-extension-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module"
6+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig } from '@rslib/core';
2+
import { generateBundleCjsConfig } from 'test-helper';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleCjsConfig({
7+
bundle: false,
8+
dts: {
9+
autoExtension: true,
10+
distPath: './dist/types',
11+
bundle: false,
12+
},
13+
}),
14+
],
15+
source: {
16+
entry: {
17+
index: ['../__fixtures__/src/**'],
18+
},
19+
},
20+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "@rslib/tsconfig/base",
3+
"compilerOptions": {
4+
"rootDir": "../__fixtures__/src",
5+
"baseUrl": "./",
6+
"composite": true
7+
},
8+
"include": ["../__fixtures__/src"]
9+
}

tests/integration/dts/index.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,21 @@ describe('dts when build: true', () => {
425425
expect(existsSync(buildInfoPath)).toBeTruthy();
426426
});
427427

428+
test('autoExtension: true', async () => {
429+
const fixturePath = join(__dirname, 'build', 'auto-extension');
430+
const { files } = await buildAndGetResults({ fixturePath, type: 'dts' });
431+
432+
expect(files.cjs).toMatchInlineSnapshot(`
433+
[
434+
"<ROOT>/tests/integration/dts/build/auto-extension/dist/types/index.d.cts",
435+
"<ROOT>/tests/integration/dts/build/auto-extension/dist/types/sum.d.cts",
436+
]
437+
`);
438+
439+
const buildInfoPath = join(fixturePath, 'tsconfig.tsbuildinfo');
440+
expect(existsSync(buildInfoPath)).toBeTruthy();
441+
});
442+
428443
test('process files - auto extension and banner / footer', async () => {
429444
const fixturePath = join(__dirname, 'build', 'process-files');
430445
const { contents } = await buildAndGetResults({
@@ -567,6 +582,20 @@ describe('dts when composite: true', () => {
567582
expect(existsSync(buildInfoPath)).toBeTruthy();
568583
});
569584

585+
test('autoExtension: true', async () => {
586+
const fixturePath = join(__dirname, 'composite', 'auto-extension');
587+
const { files } = await buildAndGetResults({ fixturePath, type: 'dts' });
588+
589+
expect(files.cjs).toMatchInlineSnapshot(`
590+
[
591+
"<ROOT>/tests/integration/dts/composite/auto-extension/dist/types/index.d.cts",
592+
"<ROOT>/tests/integration/dts/composite/auto-extension/dist/types/sum.d.cts",
593+
"<ROOT>/tests/integration/dts/composite/auto-extension/dist/types/utils/numbers.d.cts",
594+
"<ROOT>/tests/integration/dts/composite/auto-extension/dist/types/utils/strings.d.cts",
595+
]
596+
`);
597+
});
598+
570599
test('process files - auto extension and banner / footer', async () => {
571600
const fixturePath = join(__dirname, 'composite', 'process-files');
572601
const { contents } = await buildAndGetResults({

0 commit comments

Comments
 (0)