From 2216330f76af2fba831bc9af7c0cebfae515db6b Mon Sep 17 00:00:00 2001 From: Timeless0911 <50201324+Timeless0911@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:17:21 +0800 Subject: [PATCH] chore: refactor test file structure (#77) --- .../__fixtures__}/src/common.ts | 0 .../__fixtures__}/src/index.ts | 0 .../index.test.ts | 18 ++-- .../type-commonjs/default}/package.json | 0 .../type-commonjs/default}/rslib.config.ts | 2 +- .../type-commonjs/false/package.json | 5 ++ .../type-commonjs/false/rslib.config.ts} | 2 +- .../type-module/default}/package.json | 0 .../type-module/default}/rslib.config.ts | 2 +- .../type-module/false/package.json | 6 ++ .../type-module/false/rslib.config.ts} | 2 +- .../{fixtures => __fixtures__}/src/index.ts | 0 e2e/cases/auto-external/default/package.json | 2 +- .../auto-external/default/rslib.config.ts | 2 +- .../external-sub-path/package.json | 2 +- e2e/cases/auto-external/false/package.json | 2 +- e2e/cases/auto-external/false/rslib.config.ts | 2 +- .../auto-external/with-externals/package.json | 2 +- .../with-externals/rslib.config.ts | 2 +- .../autoExtension/type-module/src/common.ts | 1 - .../autoExtension/type-module/src/index.ts | 3 - .../{ => __fixtures__}/src/index.ts | 0 .../{ => __fixtures__}/src/sum.ts | 0 .../{ => __fixtures__}/src/utils/numbers.ts | 0 .../{ => __fixtures__}/src/utils/strings.ts | 0 .../bundle-false/__fixtures__}/tsconfig.json | 4 +- .../{ => abort-on-error}/rslib.config.ts | 1 + .../src}/const.ts | 0 .../src}/index.ts | 0 .../{ => abort-on-error}/tsconfig.json | 3 +- .../bundle-false/auto-extension/package.json | 6 ++ .../rslib.config.ts} | 3 +- .../rslib.config.ts} | 6 +- .../rslib.config.ts} | 3 +- .../rslib.config.ts} | 2 +- .../bundle/{ => __fixtures__}/src/index.ts | 0 .../dts/bundle/{ => __fixtures__}/src/sum.ts | 0 .../{ => __fixtures__}/src/utils/numbers.ts | 0 .../{ => __fixtures__}/src/utils/strings.ts | 0 .../bundle/{ => __fixtures__}/tsconfig.json | 3 +- .../dts/bundle/abort-on-error/package.json | 6 ++ .../{ => abort-on-error}/rslib.config.ts | 2 + .../src}/const.ts | 0 .../src}/index.ts | 0 .../abort-on-error/tsconfig.json} | 4 +- .../dts/bundle/auto-extension/package.json | 6 ++ .../rslib.config.ts} | 3 +- .../basic}/package.json | 2 +- .../rslib.config.ts} | 3 +- e2e/cases/dts/bundle/bundle-name/package.json | 6 ++ .../rslib.config.ts} | 6 +- e2e/cases/dts/bundle/dist-path/package.json | 6 ++ .../rslib.config.ts} | 3 +- e2e/cases/dts/bundle/{ => false}/package.json | 2 +- .../rslib.config.ts} | 3 +- e2e/cases/dts/bundle/tsconfig-error.json | 8 -- e2e/cases/dts/index.test.ts | 83 +++++-------------- e2e/cases/externals/browser/index.test.ts | 9 -- e2e/cases/externals/{node => }/index.test.ts | 8 +- .../{config => __fixtures__}/src/foo.ts | 0 .../{config => __fixtures__}/src/index.ts | 0 .../{config => __fixtures__}/tsconfig.json | 0 .../__snapshots__/index.test.ts.snap | 22 ++++- e2e/cases/syntax/config/index.test.ts | 12 --- e2e/cases/syntax/config/rslib.config.ts | 2 +- .../default/__snapshots__/index.test.ts.snap | 19 ----- e2e/cases/syntax/default/index.test.ts | 12 --- e2e/cases/syntax/default/rslib.config.ts | 2 +- e2e/cases/syntax/default/src/foo.ts | 9 -- e2e/cases/syntax/default/src/index.ts | 1 - e2e/cases/syntax/index.test.ts | 23 +++++ e2e/scripts/shared.ts | 3 +- packages/plugin-dts/src/tsc.ts | 4 +- pnpm-lock.yaml | 22 ++++- 74 files changed, 181 insertions(+), 196 deletions(-) rename e2e/cases/{autoExtension/type-commonjs => auto-extension/__fixtures__}/src/common.ts (100%) rename e2e/cases/{autoExtension/type-commonjs => auto-extension/__fixtures__}/src/index.ts (100%) rename e2e/cases/{autoExtension => auto-extension}/index.test.ts (71%) rename e2e/cases/{autoExtension/type-commonjs => auto-extension/type-commonjs/default}/package.json (100%) rename e2e/cases/{autoExtension/type-module => auto-extension/type-commonjs/default}/rslib.config.ts (85%) create mode 100644 e2e/cases/auto-extension/type-commonjs/false/package.json rename e2e/cases/{autoExtension/type-commonjs/autoExtension.false.config.ts => auto-extension/type-commonjs/false/rslib.config.ts} (88%) rename e2e/cases/{autoExtension/type-module => auto-extension/type-module/default}/package.json (100%) rename e2e/cases/{autoExtension/type-commonjs => auto-extension/type-module/default}/rslib.config.ts (85%) create mode 100644 e2e/cases/auto-extension/type-module/false/package.json rename e2e/cases/{autoExtension/type-module/autoExtension.false.config.ts => auto-extension/type-module/false/rslib.config.ts} (88%) rename e2e/cases/auto-external/{fixtures => __fixtures__}/src/index.ts (100%) delete mode 100644 e2e/cases/autoExtension/type-module/src/common.ts delete mode 100644 e2e/cases/autoExtension/type-module/src/index.ts rename e2e/cases/dts/bundle-false/{ => __fixtures__}/src/index.ts (100%) rename e2e/cases/dts/bundle-false/{ => __fixtures__}/src/sum.ts (100%) rename e2e/cases/dts/bundle-false/{ => __fixtures__}/src/utils/numbers.ts (100%) rename e2e/cases/dts/bundle-false/{ => __fixtures__}/src/utils/strings.ts (100%) rename e2e/cases/{syntax/default => dts/bundle-false/__fixtures__}/tsconfig.json (69%) rename e2e/cases/dts/bundle-false/{ => abort-on-error}/rslib.config.ts (93%) rename e2e/cases/dts/bundle-false/{src-error => abort-on-error/src}/const.ts (100%) rename e2e/cases/dts/bundle-false/{src-error => abort-on-error/src}/index.ts (100%) rename e2e/cases/dts/bundle-false/{ => abort-on-error}/tsconfig.json (68%) create mode 100644 e2e/cases/dts/bundle-false/auto-extension/package.json rename e2e/cases/dts/bundle-false/{autoExtension.config.ts => auto-extension/rslib.config.ts} (81%) rename e2e/cases/dts/bundle-false/{abortOnError.config.ts => basic/rslib.config.ts} (74%) rename e2e/cases/dts/bundle-false/{distPath.config.ts => dist-path/rslib.config.ts} (82%) rename e2e/cases/dts/bundle-false/{dtsFalse.config.ts => false/rslib.config.ts} (90%) rename e2e/cases/dts/bundle/{ => __fixtures__}/src/index.ts (100%) rename e2e/cases/dts/bundle/{ => __fixtures__}/src/sum.ts (100%) rename e2e/cases/dts/bundle/{ => __fixtures__}/src/utils/numbers.ts (100%) rename e2e/cases/dts/bundle/{ => __fixtures__}/src/utils/strings.ts (100%) rename e2e/cases/dts/bundle/{ => __fixtures__}/tsconfig.json (68%) create mode 100644 e2e/cases/dts/bundle/abort-on-error/package.json rename e2e/cases/dts/bundle/{ => abort-on-error}/rslib.config.ts (85%) rename e2e/cases/dts/bundle/{src-error => abort-on-error/src}/const.ts (100%) rename e2e/cases/dts/bundle/{src-error => abort-on-error/src}/index.ts (100%) rename e2e/cases/dts/{bundle-false/tsconfig-error.json => bundle/abort-on-error/tsconfig.json} (62%) create mode 100644 e2e/cases/dts/bundle/auto-extension/package.json rename e2e/cases/dts/bundle/{autoExtension.config.ts => auto-extension/rslib.config.ts} (78%) rename e2e/cases/dts/{bundle-false => bundle/basic}/package.json (64%) rename e2e/cases/dts/bundle/{bundleName.config.ts => basic/rslib.config.ts} (78%) create mode 100644 e2e/cases/dts/bundle/bundle-name/package.json rename e2e/cases/dts/bundle/{abortOnError.config.ts => bundle-name/rslib.config.ts} (71%) create mode 100644 e2e/cases/dts/bundle/dist-path/package.json rename e2e/cases/dts/bundle/{distPath.config.ts => dist-path/rslib.config.ts} (79%) rename e2e/cases/dts/bundle/{ => false}/package.json (64%) rename e2e/cases/dts/bundle/{dtsFalse.config.ts => false/rslib.config.ts} (76%) delete mode 100644 e2e/cases/dts/bundle/tsconfig-error.json delete mode 100644 e2e/cases/externals/browser/index.test.ts rename e2e/cases/externals/{node => }/index.test.ts (74%) rename e2e/cases/syntax/{config => __fixtures__}/src/foo.ts (100%) rename e2e/cases/syntax/{config => __fixtures__}/src/index.ts (100%) rename e2e/cases/syntax/{config => __fixtures__}/tsconfig.json (100%) rename e2e/cases/syntax/{config => }/__snapshots__/index.test.ts.snap (76%) delete mode 100644 e2e/cases/syntax/config/index.test.ts delete mode 100644 e2e/cases/syntax/default/__snapshots__/index.test.ts.snap delete mode 100644 e2e/cases/syntax/default/index.test.ts delete mode 100644 e2e/cases/syntax/default/src/foo.ts delete mode 100644 e2e/cases/syntax/default/src/index.ts create mode 100644 e2e/cases/syntax/index.test.ts diff --git a/e2e/cases/autoExtension/type-commonjs/src/common.ts b/e2e/cases/auto-extension/__fixtures__/src/common.ts similarity index 100% rename from e2e/cases/autoExtension/type-commonjs/src/common.ts rename to e2e/cases/auto-extension/__fixtures__/src/common.ts diff --git a/e2e/cases/autoExtension/type-commonjs/src/index.ts b/e2e/cases/auto-extension/__fixtures__/src/index.ts similarity index 100% rename from e2e/cases/autoExtension/type-commonjs/src/index.ts rename to e2e/cases/auto-extension/__fixtures__/src/index.ts diff --git a/e2e/cases/autoExtension/index.test.ts b/e2e/cases/auto-extension/index.test.ts similarity index 71% rename from e2e/cases/autoExtension/index.test.ts rename to e2e/cases/auto-extension/index.test.ts index 61ea34d29..136c7cff0 100644 --- a/e2e/cases/autoExtension/index.test.ts +++ b/e2e/cases/auto-extension/index.test.ts @@ -4,14 +4,14 @@ import { describe, expect, test } from 'vitest'; describe('autoExtension: true', () => { test('generate .mjs in build artifacts with esm format when type is commonjs', async () => { - const fixturePath = join(__dirname, 'type-commonjs'); + const fixturePath = join(__dirname, 'type-commonjs', 'default'); const { entryFiles } = await buildAndGetResults(fixturePath); expect(extname(entryFiles.esm!)).toEqual('.mjs'); expect(extname(entryFiles.cjs!)).toEqual('.js'); }); test('generate .cjs in build artifacts with cjs format when type is module', async () => { - const fixturePath = join(__dirname, 'type-module'); + const fixturePath = join(__dirname, 'type-module', 'default'); const { entryFiles } = await buildAndGetResults(fixturePath); expect(extname(entryFiles.esm!)).toEqual('.js'); expect(extname(entryFiles.cjs!)).toEqual('.cjs'); @@ -20,21 +20,15 @@ describe('autoExtension: true', () => { describe('autoExtension: false', () => { test('generate .js in both cjs and esm build artifacts when type is commonjs', async () => { - const fixturePath = join(__dirname, 'type-commonjs'); - const { entryFiles } = await buildAndGetResults( - fixturePath, - 'autoExtension.false.config.ts', - ); + const fixturePath = join(__dirname, 'type-commonjs', 'false'); + const { entryFiles } = await buildAndGetResults(fixturePath); expect(extname(entryFiles.esm!)).toEqual('.js'); expect(extname(entryFiles.cjs!)).toEqual('.js'); }); test('generate .js in both cjs and esm build artifacts when type is module', async () => { - const fixturePath = join(__dirname, 'type-module'); - const { entryFiles } = await buildAndGetResults( - fixturePath, - 'autoExtension.false.config.ts', - ); + const fixturePath = join(__dirname, 'type-module', 'false'); + const { entryFiles } = await buildAndGetResults(fixturePath); expect(extname(entryFiles.esm!)).toEqual('.js'); expect(extname(entryFiles.cjs!)).toEqual('.js'); }); diff --git a/e2e/cases/autoExtension/type-commonjs/package.json b/e2e/cases/auto-extension/type-commonjs/default/package.json similarity index 100% rename from e2e/cases/autoExtension/type-commonjs/package.json rename to e2e/cases/auto-extension/type-commonjs/default/package.json diff --git a/e2e/cases/autoExtension/type-module/rslib.config.ts b/e2e/cases/auto-extension/type-commonjs/default/rslib.config.ts similarity index 85% rename from e2e/cases/autoExtension/type-module/rslib.config.ts rename to e2e/cases/auto-extension/type-commonjs/default/rslib.config.ts index 03252f356..03e316a7e 100644 --- a/e2e/cases/autoExtension/type-module/rslib.config.ts +++ b/e2e/cases/auto-extension/type-commonjs/default/rslib.config.ts @@ -5,7 +5,7 @@ export default defineConfig({ lib: [generateBundleEsmConfig(__dirname), generateBundleCjsConfig(__dirname)], source: { entry: { - main: './src/index.ts', + main: '../../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/auto-extension/type-commonjs/false/package.json b/e2e/cases/auto-extension/type-commonjs/false/package.json new file mode 100644 index 000000000..7e90e60e9 --- /dev/null +++ b/e2e/cases/auto-extension/type-commonjs/false/package.json @@ -0,0 +1,5 @@ +{ + "name": "auto-extension-false-commonjs-test", + "version": "1.0.0", + "private": true +} diff --git a/e2e/cases/autoExtension/type-commonjs/autoExtension.false.config.ts b/e2e/cases/auto-extension/type-commonjs/false/rslib.config.ts similarity index 88% rename from e2e/cases/autoExtension/type-commonjs/autoExtension.false.config.ts rename to e2e/cases/auto-extension/type-commonjs/false/rslib.config.ts index fbb00c791..271d15adf 100644 --- a/e2e/cases/autoExtension/type-commonjs/autoExtension.false.config.ts +++ b/e2e/cases/auto-extension/type-commonjs/false/rslib.config.ts @@ -12,7 +12,7 @@ export default defineConfig({ ], source: { entry: { - main: './src/index.ts', + main: '../../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/autoExtension/type-module/package.json b/e2e/cases/auto-extension/type-module/default/package.json similarity index 100% rename from e2e/cases/autoExtension/type-module/package.json rename to e2e/cases/auto-extension/type-module/default/package.json diff --git a/e2e/cases/autoExtension/type-commonjs/rslib.config.ts b/e2e/cases/auto-extension/type-module/default/rslib.config.ts similarity index 85% rename from e2e/cases/autoExtension/type-commonjs/rslib.config.ts rename to e2e/cases/auto-extension/type-module/default/rslib.config.ts index 03252f356..03e316a7e 100644 --- a/e2e/cases/autoExtension/type-commonjs/rslib.config.ts +++ b/e2e/cases/auto-extension/type-module/default/rslib.config.ts @@ -5,7 +5,7 @@ export default defineConfig({ lib: [generateBundleEsmConfig(__dirname), generateBundleCjsConfig(__dirname)], source: { entry: { - main: './src/index.ts', + main: '../../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/auto-extension/type-module/false/package.json b/e2e/cases/auto-extension/type-module/false/package.json new file mode 100644 index 000000000..5a33607e1 --- /dev/null +++ b/e2e/cases/auto-extension/type-module/false/package.json @@ -0,0 +1,6 @@ +{ + "name": "auto-extension-false-module-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/autoExtension/type-module/autoExtension.false.config.ts b/e2e/cases/auto-extension/type-module/false/rslib.config.ts similarity index 88% rename from e2e/cases/autoExtension/type-module/autoExtension.false.config.ts rename to e2e/cases/auto-extension/type-module/false/rslib.config.ts index fbb00c791..271d15adf 100644 --- a/e2e/cases/autoExtension/type-module/autoExtension.false.config.ts +++ b/e2e/cases/auto-extension/type-module/false/rslib.config.ts @@ -12,7 +12,7 @@ export default defineConfig({ ], source: { entry: { - main: './src/index.ts', + main: '../../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/auto-external/fixtures/src/index.ts b/e2e/cases/auto-external/__fixtures__/src/index.ts similarity index 100% rename from e2e/cases/auto-external/fixtures/src/index.ts rename to e2e/cases/auto-external/__fixtures__/src/index.ts diff --git a/e2e/cases/auto-external/default/package.json b/e2e/cases/auto-external/default/package.json index 7dfa7c46f..604cb35a2 100644 --- a/e2e/cases/auto-external/default/package.json +++ b/e2e/cases/auto-external/default/package.json @@ -1,5 +1,5 @@ { - "name": "@e2e/auto-external-default", + "name": "auto-external-default-test", "dependencies": { "react": "^18.3.1" } diff --git a/e2e/cases/auto-external/default/rslib.config.ts b/e2e/cases/auto-external/default/rslib.config.ts index 6f1252ecf..549d8c880 100644 --- a/e2e/cases/auto-external/default/rslib.config.ts +++ b/e2e/cases/auto-external/default/rslib.config.ts @@ -5,7 +5,7 @@ export default defineConfig({ lib: [generateBundleEsmConfig(__dirname), generateBundleCjsConfig(__dirname)], source: { entry: { - main: '../fixtures/src/index.ts', + main: '../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/auto-external/external-sub-path/package.json b/e2e/cases/auto-external/external-sub-path/package.json index 5c98adea0..5deba7435 100644 --- a/e2e/cases/auto-external/external-sub-path/package.json +++ b/e2e/cases/auto-external/external-sub-path/package.json @@ -1,5 +1,5 @@ { - "name": "@e2e/auto-external-with-sub-path", + "name": "auto-external-with-sub-path-test", "dependencies": { "react": "^18.3.1" } diff --git a/e2e/cases/auto-external/false/package.json b/e2e/cases/auto-external/false/package.json index 6fe114ccc..ac906f308 100644 --- a/e2e/cases/auto-external/false/package.json +++ b/e2e/cases/auto-external/false/package.json @@ -1,5 +1,5 @@ { - "name": "@e2e/auto-external-false", + "name": "auto-external-false-test", "dependencies": { "react": "^18.3.1" } diff --git a/e2e/cases/auto-external/false/rslib.config.ts b/e2e/cases/auto-external/false/rslib.config.ts index 3a82365bd..05923f5e1 100644 --- a/e2e/cases/auto-external/false/rslib.config.ts +++ b/e2e/cases/auto-external/false/rslib.config.ts @@ -14,7 +14,7 @@ export default defineConfig({ ], source: { entry: { - main: '../fixtures/src/index.ts', + main: '../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/auto-external/with-externals/package.json b/e2e/cases/auto-external/with-externals/package.json index 9d79d0669..e20b5d59c 100644 --- a/e2e/cases/auto-external/with-externals/package.json +++ b/e2e/cases/auto-external/with-externals/package.json @@ -1,5 +1,5 @@ { - "name": "@e2e/auto-external-with-externals", + "name": "auto-external-with-externals-test", "dependencies": { "react": "^18.3.1" } diff --git a/e2e/cases/auto-external/with-externals/rslib.config.ts b/e2e/cases/auto-external/with-externals/rslib.config.ts index 96d469e63..6aadaf20b 100644 --- a/e2e/cases/auto-external/with-externals/rslib.config.ts +++ b/e2e/cases/auto-external/with-externals/rslib.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ }, source: { entry: { - main: '../fixtures/src/index.ts', + main: '../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/autoExtension/type-module/src/common.ts b/e2e/cases/autoExtension/type-module/src/common.ts deleted file mode 100644 index cc798ff50..000000000 --- a/e2e/cases/autoExtension/type-module/src/common.ts +++ /dev/null @@ -1 +0,0 @@ -export const a = 1; diff --git a/e2e/cases/autoExtension/type-module/src/index.ts b/e2e/cases/autoExtension/type-module/src/index.ts deleted file mode 100644 index b5f5ad8ce..000000000 --- a/e2e/cases/autoExtension/type-module/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { a } from './common'; - -console.log(a); diff --git a/e2e/cases/dts/bundle-false/src/index.ts b/e2e/cases/dts/bundle-false/__fixtures__/src/index.ts similarity index 100% rename from e2e/cases/dts/bundle-false/src/index.ts rename to e2e/cases/dts/bundle-false/__fixtures__/src/index.ts diff --git a/e2e/cases/dts/bundle-false/src/sum.ts b/e2e/cases/dts/bundle-false/__fixtures__/src/sum.ts similarity index 100% rename from e2e/cases/dts/bundle-false/src/sum.ts rename to e2e/cases/dts/bundle-false/__fixtures__/src/sum.ts diff --git a/e2e/cases/dts/bundle-false/src/utils/numbers.ts b/e2e/cases/dts/bundle-false/__fixtures__/src/utils/numbers.ts similarity index 100% rename from e2e/cases/dts/bundle-false/src/utils/numbers.ts rename to e2e/cases/dts/bundle-false/__fixtures__/src/utils/numbers.ts diff --git a/e2e/cases/dts/bundle-false/src/utils/strings.ts b/e2e/cases/dts/bundle-false/__fixtures__/src/utils/strings.ts similarity index 100% rename from e2e/cases/dts/bundle-false/src/utils/strings.ts rename to e2e/cases/dts/bundle-false/__fixtures__/src/utils/strings.ts diff --git a/e2e/cases/syntax/default/tsconfig.json b/e2e/cases/dts/bundle-false/__fixtures__/tsconfig.json similarity index 69% rename from e2e/cases/syntax/default/tsconfig.json rename to e2e/cases/dts/bundle-false/__fixtures__/tsconfig.json index ae0b87df5..0fccc577b 100644 --- a/e2e/cases/syntax/default/tsconfig.json +++ b/e2e/cases/dts/bundle-false/__fixtures__/tsconfig.json @@ -2,9 +2,7 @@ "extends": "@rslib/tsconfig/base", "compilerOptions": { "baseUrl": "./", - "paths": { - "@src/*": ["./src/*"] - } + "rootDir": "src" }, "include": ["src"] } diff --git a/e2e/cases/dts/bundle-false/rslib.config.ts b/e2e/cases/dts/bundle-false/abort-on-error/rslib.config.ts similarity index 93% rename from e2e/cases/dts/bundle-false/rslib.config.ts rename to e2e/cases/dts/bundle-false/abort-on-error/rslib.config.ts index 0dc33ac98..8b29fd58b 100644 --- a/e2e/cases/dts/bundle-false/rslib.config.ts +++ b/e2e/cases/dts/bundle-false/abort-on-error/rslib.config.ts @@ -7,6 +7,7 @@ export default defineConfig({ bundle: false, dts: { bundle: false, + abortOnError: false, }, }), generateBundleCjsConfig(__dirname, { diff --git a/e2e/cases/dts/bundle-false/src-error/const.ts b/e2e/cases/dts/bundle-false/abort-on-error/src/const.ts similarity index 100% rename from e2e/cases/dts/bundle-false/src-error/const.ts rename to e2e/cases/dts/bundle-false/abort-on-error/src/const.ts diff --git a/e2e/cases/dts/bundle-false/src-error/index.ts b/e2e/cases/dts/bundle-false/abort-on-error/src/index.ts similarity index 100% rename from e2e/cases/dts/bundle-false/src-error/index.ts rename to e2e/cases/dts/bundle-false/abort-on-error/src/index.ts diff --git a/e2e/cases/dts/bundle-false/tsconfig.json b/e2e/cases/dts/bundle-false/abort-on-error/tsconfig.json similarity index 68% rename from e2e/cases/dts/bundle-false/tsconfig.json rename to e2e/cases/dts/bundle-false/abort-on-error/tsconfig.json index 888d3e460..0fccc577b 100644 --- a/e2e/cases/dts/bundle-false/tsconfig.json +++ b/e2e/cases/dts/bundle-false/abort-on-error/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "@rslib/tsconfig/base", "compilerOptions": { - "baseUrl": "./" + "baseUrl": "./", + "rootDir": "src" }, "include": ["src"] } diff --git a/e2e/cases/dts/bundle-false/auto-extension/package.json b/e2e/cases/dts/bundle-false/auto-extension/package.json new file mode 100644 index 000000000..11db2552f --- /dev/null +++ b/e2e/cases/dts/bundle-false/auto-extension/package.json @@ -0,0 +1,6 @@ +{ + "name": "dts-bundle-false-auto-extension-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/dts/bundle-false/autoExtension.config.ts b/e2e/cases/dts/bundle-false/auto-extension/rslib.config.ts similarity index 81% rename from e2e/cases/dts/bundle-false/autoExtension.config.ts rename to e2e/cases/dts/bundle-false/auto-extension/rslib.config.ts index 39499785f..8dfb9ba1c 100644 --- a/e2e/cases/dts/bundle-false/autoExtension.config.ts +++ b/e2e/cases/dts/bundle-false/auto-extension/rslib.config.ts @@ -15,7 +15,8 @@ export default defineConfig({ ], source: { entry: { - main: ['./src/**'], + main: ['../__fixtures__/src/**'], }, + tsconfigPath: '../__fixtures__/tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle-false/abortOnError.config.ts b/e2e/cases/dts/bundle-false/basic/rslib.config.ts similarity index 74% rename from e2e/cases/dts/bundle-false/abortOnError.config.ts rename to e2e/cases/dts/bundle-false/basic/rslib.config.ts index 8d47abb76..f38659d26 100644 --- a/e2e/cases/dts/bundle-false/abortOnError.config.ts +++ b/e2e/cases/dts/bundle-false/basic/rslib.config.ts @@ -7,8 +7,6 @@ export default defineConfig({ bundle: false, dts: { bundle: false, - distPath: './dist/error', - abortOnError: false, }, }), generateBundleCjsConfig(__dirname, { @@ -17,8 +15,8 @@ export default defineConfig({ ], source: { entry: { - main: ['./src-error/**'], + main: ['../__fixtures__/src/**'], }, - tsconfigPath: 'tsconfig-error.json', + tsconfigPath: '../__fixtures__/tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle-false/distPath.config.ts b/e2e/cases/dts/bundle-false/dist-path/rslib.config.ts similarity index 82% rename from e2e/cases/dts/bundle-false/distPath.config.ts rename to e2e/cases/dts/bundle-false/dist-path/rslib.config.ts index fcb9d056c..59cf68ee7 100644 --- a/e2e/cases/dts/bundle-false/distPath.config.ts +++ b/e2e/cases/dts/bundle-false/dist-path/rslib.config.ts @@ -16,7 +16,8 @@ export default defineConfig({ ], source: { entry: { - main: ['./src/**'], + main: ['../__fixtures__/src/**'], }, + tsconfigPath: '../__fixtures__/tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle-false/dtsFalse.config.ts b/e2e/cases/dts/bundle-false/false/rslib.config.ts similarity index 90% rename from e2e/cases/dts/bundle-false/dtsFalse.config.ts rename to e2e/cases/dts/bundle-false/false/rslib.config.ts index dc0adc946..dc88d2f0f 100644 --- a/e2e/cases/dts/bundle-false/dtsFalse.config.ts +++ b/e2e/cases/dts/bundle-false/false/rslib.config.ts @@ -13,7 +13,7 @@ export default defineConfig({ ], source: { entry: { - main: ['./src/**'], + main: ['../__fixtures__/src/**'], }, }, }); diff --git a/e2e/cases/dts/bundle/src/index.ts b/e2e/cases/dts/bundle/__fixtures__/src/index.ts similarity index 100% rename from e2e/cases/dts/bundle/src/index.ts rename to e2e/cases/dts/bundle/__fixtures__/src/index.ts diff --git a/e2e/cases/dts/bundle/src/sum.ts b/e2e/cases/dts/bundle/__fixtures__/src/sum.ts similarity index 100% rename from e2e/cases/dts/bundle/src/sum.ts rename to e2e/cases/dts/bundle/__fixtures__/src/sum.ts diff --git a/e2e/cases/dts/bundle/src/utils/numbers.ts b/e2e/cases/dts/bundle/__fixtures__/src/utils/numbers.ts similarity index 100% rename from e2e/cases/dts/bundle/src/utils/numbers.ts rename to e2e/cases/dts/bundle/__fixtures__/src/utils/numbers.ts diff --git a/e2e/cases/dts/bundle/src/utils/strings.ts b/e2e/cases/dts/bundle/__fixtures__/src/utils/strings.ts similarity index 100% rename from e2e/cases/dts/bundle/src/utils/strings.ts rename to e2e/cases/dts/bundle/__fixtures__/src/utils/strings.ts diff --git a/e2e/cases/dts/bundle/tsconfig.json b/e2e/cases/dts/bundle/__fixtures__/tsconfig.json similarity index 68% rename from e2e/cases/dts/bundle/tsconfig.json rename to e2e/cases/dts/bundle/__fixtures__/tsconfig.json index 888d3e460..0fccc577b 100644 --- a/e2e/cases/dts/bundle/tsconfig.json +++ b/e2e/cases/dts/bundle/__fixtures__/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "@rslib/tsconfig/base", "compilerOptions": { - "baseUrl": "./" + "baseUrl": "./", + "rootDir": "src" }, "include": ["src"] } diff --git a/e2e/cases/dts/bundle/abort-on-error/package.json b/e2e/cases/dts/bundle/abort-on-error/package.json new file mode 100644 index 000000000..41740a60d --- /dev/null +++ b/e2e/cases/dts/bundle/abort-on-error/package.json @@ -0,0 +1,6 @@ +{ + "name": "dts-bundle-abort-on-error-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/dts/bundle/rslib.config.ts b/e2e/cases/dts/bundle/abort-on-error/rslib.config.ts similarity index 85% rename from e2e/cases/dts/bundle/rslib.config.ts rename to e2e/cases/dts/bundle/abort-on-error/rslib.config.ts index bed75189e..f107f48ff 100644 --- a/e2e/cases/dts/bundle/rslib.config.ts +++ b/e2e/cases/dts/bundle/abort-on-error/rslib.config.ts @@ -6,6 +6,7 @@ export default defineConfig({ generateBundleEsmConfig(__dirname, { dts: { bundle: true, + abortOnError: false, }, }), generateBundleCjsConfig(__dirname), @@ -14,5 +15,6 @@ export default defineConfig({ entry: { main: './src/index.ts', }, + tsconfigPath: 'tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle/src-error/const.ts b/e2e/cases/dts/bundle/abort-on-error/src/const.ts similarity index 100% rename from e2e/cases/dts/bundle/src-error/const.ts rename to e2e/cases/dts/bundle/abort-on-error/src/const.ts diff --git a/e2e/cases/dts/bundle/src-error/index.ts b/e2e/cases/dts/bundle/abort-on-error/src/index.ts similarity index 100% rename from e2e/cases/dts/bundle/src-error/index.ts rename to e2e/cases/dts/bundle/abort-on-error/src/index.ts diff --git a/e2e/cases/dts/bundle-false/tsconfig-error.json b/e2e/cases/dts/bundle/abort-on-error/tsconfig.json similarity index 62% rename from e2e/cases/dts/bundle-false/tsconfig-error.json rename to e2e/cases/dts/bundle/abort-on-error/tsconfig.json index 30f7bdb10..0fccc577b 100644 --- a/e2e/cases/dts/bundle-false/tsconfig-error.json +++ b/e2e/cases/dts/bundle/abort-on-error/tsconfig.json @@ -2,7 +2,7 @@ "extends": "@rslib/tsconfig/base", "compilerOptions": { "baseUrl": "./", - "rootDir": "src-error" + "rootDir": "src" }, - "include": ["src-error"] + "include": ["src"] } diff --git a/e2e/cases/dts/bundle/auto-extension/package.json b/e2e/cases/dts/bundle/auto-extension/package.json new file mode 100644 index 000000000..0ce3ef29c --- /dev/null +++ b/e2e/cases/dts/bundle/auto-extension/package.json @@ -0,0 +1,6 @@ +{ + "name": "dts-bundle-auto-extension-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/dts/bundle/autoExtension.config.ts b/e2e/cases/dts/bundle/auto-extension/rslib.config.ts similarity index 78% rename from e2e/cases/dts/bundle/autoExtension.config.ts rename to e2e/cases/dts/bundle/auto-extension/rslib.config.ts index c58dcca06..69ca77fb6 100644 --- a/e2e/cases/dts/bundle/autoExtension.config.ts +++ b/e2e/cases/dts/bundle/auto-extension/rslib.config.ts @@ -12,7 +12,8 @@ export default defineConfig({ ], source: { entry: { - main: './src/index.ts', + main: '../__fixtures__/src/index.ts', }, + tsconfigPath: '../__fixtures__/tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle-false/package.json b/e2e/cases/dts/bundle/basic/package.json similarity index 64% rename from e2e/cases/dts/bundle-false/package.json rename to e2e/cases/dts/bundle/basic/package.json index aa0ce962e..305d84a6f 100644 --- a/e2e/cases/dts/bundle-false/package.json +++ b/e2e/cases/dts/bundle/basic/package.json @@ -1,5 +1,5 @@ { - "name": "dts-bundle-false-test", + "name": "dts-bundle-basic-test", "version": "1.0.0", "private": true, "type": "module" diff --git a/e2e/cases/dts/bundle/bundleName.config.ts b/e2e/cases/dts/bundle/basic/rslib.config.ts similarity index 78% rename from e2e/cases/dts/bundle/bundleName.config.ts rename to e2e/cases/dts/bundle/basic/rslib.config.ts index 6cdca50fa..ef3fd91ac 100644 --- a/e2e/cases/dts/bundle/bundleName.config.ts +++ b/e2e/cases/dts/bundle/basic/rslib.config.ts @@ -12,7 +12,8 @@ export default defineConfig({ ], source: { entry: { - bundleName: './src/index.ts', + main: '../__fixtures__/src/index.ts', }, + tsconfigPath: '../__fixtures__/tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle/bundle-name/package.json b/e2e/cases/dts/bundle/bundle-name/package.json new file mode 100644 index 000000000..72dc7adb4 --- /dev/null +++ b/e2e/cases/dts/bundle/bundle-name/package.json @@ -0,0 +1,6 @@ +{ + "name": "dts-bundle-bundle-name-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/dts/bundle/abortOnError.config.ts b/e2e/cases/dts/bundle/bundle-name/rslib.config.ts similarity index 71% rename from e2e/cases/dts/bundle/abortOnError.config.ts rename to e2e/cases/dts/bundle/bundle-name/rslib.config.ts index 532814991..837df5add 100644 --- a/e2e/cases/dts/bundle/abortOnError.config.ts +++ b/e2e/cases/dts/bundle/bundle-name/rslib.config.ts @@ -6,16 +6,14 @@ export default defineConfig({ generateBundleEsmConfig(__dirname, { dts: { bundle: true, - distPath: './dist/error', - abortOnError: false, }, }), generateBundleCjsConfig(__dirname), ], source: { entry: { - main: './src-error/index.ts', + bundleName: '../__fixtures__/src/index.ts', }, - tsconfigPath: 'tsconfig-error.json', + tsconfigPath: '../__fixtures__/tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle/dist-path/package.json b/e2e/cases/dts/bundle/dist-path/package.json new file mode 100644 index 000000000..c76fa18cf --- /dev/null +++ b/e2e/cases/dts/bundle/dist-path/package.json @@ -0,0 +1,6 @@ +{ + "name": "dts-bundle-dist-path-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/dts/bundle/distPath.config.ts b/e2e/cases/dts/bundle/dist-path/rslib.config.ts similarity index 79% rename from e2e/cases/dts/bundle/distPath.config.ts rename to e2e/cases/dts/bundle/dist-path/rslib.config.ts index 2adf35fb8..c7492c387 100644 --- a/e2e/cases/dts/bundle/distPath.config.ts +++ b/e2e/cases/dts/bundle/dist-path/rslib.config.ts @@ -13,7 +13,8 @@ export default defineConfig({ ], source: { entry: { - main: './src/index.ts', + main: '../__fixtures__/src/index.ts', }, + tsconfigPath: '../__fixtures__/tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle/package.json b/e2e/cases/dts/bundle/false/package.json similarity index 64% rename from e2e/cases/dts/bundle/package.json rename to e2e/cases/dts/bundle/false/package.json index 77cf18a4e..a467997df 100644 --- a/e2e/cases/dts/bundle/package.json +++ b/e2e/cases/dts/bundle/false/package.json @@ -1,5 +1,5 @@ { - "name": "dts-bundle-test", + "name": "dts-false-bundle-test", "version": "1.0.0", "private": true, "type": "module" diff --git a/e2e/cases/dts/bundle/dtsFalse.config.ts b/e2e/cases/dts/bundle/false/rslib.config.ts similarity index 76% rename from e2e/cases/dts/bundle/dtsFalse.config.ts rename to e2e/cases/dts/bundle/false/rslib.config.ts index 631fd8e0b..f7e4a0964 100644 --- a/e2e/cases/dts/bundle/dtsFalse.config.ts +++ b/e2e/cases/dts/bundle/false/rslib.config.ts @@ -10,7 +10,8 @@ export default defineConfig({ ], source: { entry: { - main: './src/index.ts', + main: '../__fixtures__/src/index.ts', }, + tsconfigPath: '../__fixtures__/tsconfig.json', }, }); diff --git a/e2e/cases/dts/bundle/tsconfig-error.json b/e2e/cases/dts/bundle/tsconfig-error.json deleted file mode 100644 index 30f7bdb10..000000000 --- a/e2e/cases/dts/bundle/tsconfig-error.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "@rslib/tsconfig/base", - "compilerOptions": { - "baseUrl": "./", - "rootDir": "src-error" - }, - "include": ["src-error"] -} diff --git a/e2e/cases/dts/index.test.ts b/e2e/cases/dts/index.test.ts index 08e0a903d..979218c5a 100644 --- a/e2e/cases/dts/index.test.ts +++ b/e2e/cases/dts/index.test.ts @@ -4,12 +4,8 @@ import { describe, expect, test } from 'vitest'; describe('dts when bundle: false', () => { test('basic', async () => { - const fixturePath = join(__dirname, 'bundle-false'); - const { files, contents } = await buildAndGetResults( - fixturePath, - 'rslib.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle-false', 'basic'); + const { files, contents } = await buildAndGetResults(fixturePath, 'dts'); expect(files.esm).toMatchInlineSnapshot(` [ @@ -23,23 +19,15 @@ describe('dts when bundle: false', () => { }); test('dts false', async () => { - const fixturePath = join(__dirname, 'bundle-false'); - const { files } = await buildAndGetResults( - fixturePath, - 'dtsFalse.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle-false', 'false'); + const { files } = await buildAndGetResults(fixturePath, 'dts'); expect(files.esm).toBe(undefined); }); test('distPath', async () => { - const fixturePath = join(__dirname, 'bundle-false'); - const { files } = await buildAndGetResults( - fixturePath, - 'distPath.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle-false', 'dist-path'); + const { files } = await buildAndGetResults(fixturePath, 'dts'); expect(files.esm).toMatchInlineSnapshot(` [ @@ -52,23 +40,15 @@ describe('dts when bundle: false', () => { }); test('abortOnError: false', async () => { - const fixturePath = join(__dirname, 'bundle-false'); - const { isSuccess } = await buildAndGetResults( - fixturePath, - 'abortOnError.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle-false', 'abort-on-error'); + const { isSuccess } = await buildAndGetResults(fixturePath, 'dts'); expect(isSuccess).toBe(true); }); test('autoExtension: true', async () => { - const fixturePath = join(__dirname, 'bundle-false'); - const { files } = await buildAndGetResults( - fixturePath, - 'autoExtension.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle-false', 'auto-extension'); + const { files } = await buildAndGetResults(fixturePath, 'dts'); expect(files.cjs).toMatchInlineSnapshot(` [ @@ -83,10 +63,9 @@ describe('dts when bundle: false', () => { describe('dts when bundle: true', () => { test('basic', async () => { - const fixturePath = join(__dirname, 'bundle'); + const fixturePath = join(__dirname, 'bundle', 'basic'); const { entryFiles, entries } = await buildAndGetResults( fixturePath, - 'rslib.config.ts', 'dts', ); @@ -95,56 +74,36 @@ describe('dts when bundle: true', () => { }); test('dts false', async () => { - const fixturePath = join(__dirname, 'bundle'); - const { entryFiles } = await buildAndGetResults( - fixturePath, - 'dtsFalse.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle', 'false'); + const { entryFiles } = await buildAndGetResults(fixturePath, 'dts'); expect(entryFiles.esm).toEqual(undefined); }); test('distPath', async () => { - const fixturePath = join(__dirname, 'bundle'); - const { entryFiles } = await buildAndGetResults( - fixturePath, - 'distPath.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle', 'dist-path'); + const { entryFiles } = await buildAndGetResults(fixturePath, 'dts'); expect(entryFiles.esm).toEqual('./dist/custom/main.d.ts'); }); test('abortOnError: false', async () => { - const fixturePath = join(__dirname, 'bundle'); - const { isSuccess } = await buildAndGetResults( - fixturePath, - 'abortOnError.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle', 'abort-on-error'); + const { isSuccess } = await buildAndGetResults(fixturePath, 'dts'); expect(isSuccess).toBe(true); }); test('autoExtension: true', async () => { - const fixturePath = join(__dirname, 'bundle'); - const { entryFiles } = await buildAndGetResults( - fixturePath, - 'autoExtension.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle', 'auto-extension'); + const { entryFiles } = await buildAndGetResults(fixturePath, 'dts'); expect(entryFiles.cjs).toEqual('./dist/cjs/main.d.cts'); }); test('bundleName -- set source.entry', async () => { - const fixturePath = join(__dirname, 'bundle'); - const { entryFiles } = await buildAndGetResults( - fixturePath, - 'bundleName.config.ts', - 'dts', - ); + const fixturePath = join(__dirname, 'bundle', 'bundle-name'); + const { entryFiles } = await buildAndGetResults(fixturePath, 'dts'); expect(entryFiles.esm).toEqual('./dist/esm/bundleName.d.ts'); }); diff --git a/e2e/cases/externals/browser/index.test.ts b/e2e/cases/externals/browser/index.test.ts deleted file mode 100644 index 87f80ab5a..000000000 --- a/e2e/cases/externals/browser/index.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { join } from 'node:path'; -import { buildAndGetResults } from '@e2e/helper'; -import { expect, test } from 'vitest'; - -test('should fail to build when `output.target` is not "node"', async () => { - const fixturePath = join(__dirname); - const build = buildAndGetResults(fixturePath); - await expect(build).rejects.toThrowError('Rspack build failed!'); -}); diff --git a/e2e/cases/externals/node/index.test.ts b/e2e/cases/externals/index.test.ts similarity index 74% rename from e2e/cases/externals/node/index.test.ts rename to e2e/cases/externals/index.test.ts index 8e15fdce2..9df5070e4 100644 --- a/e2e/cases/externals/node/index.test.ts +++ b/e2e/cases/externals/index.test.ts @@ -2,8 +2,14 @@ import { join } from 'node:path'; import { buildAndGetResults } from '@e2e/helper'; import { expect, test } from 'vitest'; +test('should fail to build when `output.target` is not "node"', async () => { + const fixturePath = join(__dirname, 'browser'); + const build = buildAndGetResults(fixturePath); + await expect(build).rejects.toThrowError('Rspack build failed!'); +}); + test('auto externalize Node.js built-in modules when `output.target` is "node"', async () => { - const fixturePath = join(__dirname); + const fixturePath = join(__dirname, 'node'); const { entries } = await buildAndGetResults(fixturePath); for (const external of [ diff --git a/e2e/cases/syntax/config/src/foo.ts b/e2e/cases/syntax/__fixtures__/src/foo.ts similarity index 100% rename from e2e/cases/syntax/config/src/foo.ts rename to e2e/cases/syntax/__fixtures__/src/foo.ts diff --git a/e2e/cases/syntax/config/src/index.ts b/e2e/cases/syntax/__fixtures__/src/index.ts similarity index 100% rename from e2e/cases/syntax/config/src/index.ts rename to e2e/cases/syntax/__fixtures__/src/index.ts diff --git a/e2e/cases/syntax/config/tsconfig.json b/e2e/cases/syntax/__fixtures__/tsconfig.json similarity index 100% rename from e2e/cases/syntax/config/tsconfig.json rename to e2e/cases/syntax/__fixtures__/tsconfig.json diff --git a/e2e/cases/syntax/config/__snapshots__/index.test.ts.snap b/e2e/cases/syntax/__snapshots__/index.test.ts.snap similarity index 76% rename from e2e/cases/syntax/config/__snapshots__/index.test.ts.snap rename to e2e/cases/syntax/__snapshots__/index.test.ts.snap index 68ee31a6a..7931dc64c 100644 --- a/e2e/cases/syntax/config/__snapshots__/index.test.ts.snap +++ b/e2e/cases/syntax/__snapshots__/index.test.ts.snap @@ -2,6 +2,24 @@ exports[`should downgrade class private method by default 1`] = ` " +;// CONCATENATED MODULE: ../__fixtures__/src/foo.ts +class Foo { + constructor(){ + this.#bar(); + } + #bar() {} +} + + +;// CONCATENATED MODULE: ../__fixtures__/src/index.ts + + +export { Foo }; +" +`; + +exports[`should downgrade class private method with output.syntax config 1`] = ` +" ;// CONCATENATED MODULE: ../../../../node_modules/.pnpm/@swc+helpers@0.5.11/node_modules/@swc/helpers/esm/_class_private_method_get.js function _class_private_method_get(receiver, privateSet, fn) { if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance"); @@ -27,7 +45,7 @@ function _class_private_method_init(obj, privateSet) { } -;// CONCATENATED MODULE: ./src/foo.ts +;// CONCATENATED MODULE: ../__fixtures__/src/foo.ts var _bar = new WeakSet(); @@ -40,7 +58,7 @@ class Foo { function bar() {} /*#__PURE__*/ -;// CONCATENATED MODULE: ./src/index.ts +;// CONCATENATED MODULE: ../__fixtures__/src/index.ts export { Foo }; diff --git a/e2e/cases/syntax/config/index.test.ts b/e2e/cases/syntax/config/index.test.ts deleted file mode 100644 index 3f023169e..000000000 --- a/e2e/cases/syntax/config/index.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { buildAndGetResults } from '@e2e/helper'; -import { expect, test } from 'vitest'; - -test('should downgrade class private method by default', async () => { - const fixturePath = __dirname; - const { entries } = await buildAndGetResults(fixturePath); - - expect(entries.esm).toMatchSnapshot(); - expect(entries.esm).not.toContain('#bar'); - - expect(entries.cjs).toContain('#bar'); -}); diff --git a/e2e/cases/syntax/config/rslib.config.ts b/e2e/cases/syntax/config/rslib.config.ts index bb42798e4..ee9a3be17 100644 --- a/e2e/cases/syntax/config/rslib.config.ts +++ b/e2e/cases/syntax/config/rslib.config.ts @@ -16,7 +16,7 @@ export default defineConfig({ ], source: { entry: { - main: './src/index.ts', + main: '../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/syntax/default/__snapshots__/index.test.ts.snap b/e2e/cases/syntax/default/__snapshots__/index.test.ts.snap deleted file mode 100644 index 01153bb39..000000000 --- a/e2e/cases/syntax/default/__snapshots__/index.test.ts.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`should downgrade class private method by default 1`] = ` -" -;// CONCATENATED MODULE: ./src/foo.ts -class Foo { - constructor(){ - this.#bar(); - } - #bar() {} -} - - -;// CONCATENATED MODULE: ./src/index.ts - - -export { Foo }; -" -`; diff --git a/e2e/cases/syntax/default/index.test.ts b/e2e/cases/syntax/default/index.test.ts deleted file mode 100644 index 71ec97dbf..000000000 --- a/e2e/cases/syntax/default/index.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { buildAndGetResults } from '@e2e/helper'; -import { expect, test } from 'vitest'; - -test('should downgrade class private method by default', async () => { - const fixturePath = __dirname; - const { entries } = await buildAndGetResults(fixturePath); - - expect(entries.esm).toMatchSnapshot(); - expect(entries.esm).toContain('#bar'); - - expect(entries.cjs).toContain('#bar'); -}); diff --git a/e2e/cases/syntax/default/rslib.config.ts b/e2e/cases/syntax/default/rslib.config.ts index 03252f356..549d8c880 100644 --- a/e2e/cases/syntax/default/rslib.config.ts +++ b/e2e/cases/syntax/default/rslib.config.ts @@ -5,7 +5,7 @@ export default defineConfig({ lib: [generateBundleEsmConfig(__dirname), generateBundleCjsConfig(__dirname)], source: { entry: { - main: './src/index.ts', + main: '../__fixtures__/src/index.ts', }, }, }); diff --git a/e2e/cases/syntax/default/src/foo.ts b/e2e/cases/syntax/default/src/foo.ts deleted file mode 100644 index 7ce034c38..000000000 --- a/e2e/cases/syntax/default/src/foo.ts +++ /dev/null @@ -1,9 +0,0 @@ -class Foo { - constructor() { - this.#bar(); - } - - #bar() {} -} - -export { Foo }; diff --git a/e2e/cases/syntax/default/src/index.ts b/e2e/cases/syntax/default/src/index.ts deleted file mode 100644 index 38eca28a6..000000000 --- a/e2e/cases/syntax/default/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Foo } from './foo'; diff --git a/e2e/cases/syntax/index.test.ts b/e2e/cases/syntax/index.test.ts new file mode 100644 index 000000000..657e44421 --- /dev/null +++ b/e2e/cases/syntax/index.test.ts @@ -0,0 +1,23 @@ +import { join } from 'node:path'; +import { buildAndGetResults } from '@e2e/helper'; +import { expect, test } from 'vitest'; + +test('should downgrade class private method by default', async () => { + const fixturePath = join(__dirname, 'default'); + const { entries } = await buildAndGetResults(fixturePath); + + expect(entries.esm).toMatchSnapshot(); + expect(entries.esm).toContain('#bar'); + + expect(entries.cjs).toContain('#bar'); +}); + +test('should downgrade class private method with output.syntax config', async () => { + const fixturePath = join(__dirname, 'config'); + const { entries } = await buildAndGetResults(fixturePath); + + expect(entries.esm).toMatchSnapshot(); + expect(entries.esm).not.toContain('#bar'); + + expect(entries.cjs).toContain('#bar'); +}); diff --git a/e2e/scripts/shared.ts b/e2e/scripts/shared.ts index f1e950fd0..f67d48fb7 100644 --- a/e2e/scripts/shared.ts +++ b/e2e/scripts/shared.ts @@ -104,7 +104,6 @@ export async function getResults( export const buildAndGetResults = async ( fixturePath: string, - configFile = 'rslib.config.ts', type: 'js' | 'dts' = 'js', ): Promise<{ contents: Record>; @@ -115,7 +114,7 @@ export const buildAndGetResults = async ( rsbuildConfig: InspectConfigResult['origin']['rsbuildConfig']; isSuccess: boolean; }> => { - const rslibConfig = await loadConfig(join(fixturePath, configFile)); + const rslibConfig = await loadConfig(join(fixturePath, 'rslib.config.ts')); process.chdir(fixturePath); const rsbuildInstance = await build(rslibConfig); const { diff --git a/packages/plugin-dts/src/tsc.ts b/packages/plugin-dts/src/tsc.ts index 3ee73b0fa..957635f37 100644 --- a/packages/plugin-dts/src/tsc.ts +++ b/packages/plugin-dts/src/tsc.ts @@ -8,7 +8,7 @@ import { processDtsFiles, } from './utils'; -export type emitDtsOptions = { +export type EmitDtsOptions = { name: string; cwd: string; configPath: string; @@ -18,7 +18,7 @@ export type emitDtsOptions = { }; export async function emitDts( - options: emitDtsOptions, + options: EmitDtsOptions, onComplete: (isSuccess: boolean) => void, bundle = false, isWatch = false, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aea969d95..432e421c9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -94,6 +94,14 @@ importers: specifier: ^11.2.0 version: 11.2.0 + e2e/cases/auto-extension/type-commonjs/default: {} + + e2e/cases/auto-extension/type-commonjs/false: {} + + e2e/cases/auto-extension/type-module/default: {} + + e2e/cases/auto-extension/type-module/false: {} + e2e/cases/auto-external/default: dependencies: react: @@ -118,13 +126,19 @@ importers: specifier: ^18.3.1 version: 18.3.1 - e2e/cases/autoExtension/type-commonjs: {} + e2e/cases/dts/bundle-false/auto-extension: {} + + e2e/cases/dts/bundle/abort-on-error: {} + + e2e/cases/dts/bundle/auto-extension: {} + + e2e/cases/dts/bundle/basic: {} - e2e/cases/autoExtension/type-module: {} + e2e/cases/dts/bundle/bundle-name: {} - e2e/cases/dts/bundle: {} + e2e/cases/dts/bundle/dist-path: {} - e2e/cases/dts/bundle-false: {} + e2e/cases/dts/bundle/false: {} e2e/scripts: {}