From 3b0eb8523a8af5b99b21f573026847c74157e5ec Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 16 Jan 2024 04:35:27 -0600 Subject: [PATCH] test: add ts composite test case (#414) Co-authored-by: Jiachi Liu --- test/integration.test.ts | 16 +++++++++++++++- test/integration/monorepo/package.json | 6 ++++++ .../monorepo/packages/package/package.json | 5 +++++ .../monorepo/packages/package/src/index.ts | 3 +++ .../monorepo/packages/package/tsconfig.json | 7 +++++++ test/integration/monorepo/tsconfig.json | 11 +++++++++++ 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/integration/monorepo/package.json create mode 100644 test/integration/monorepo/packages/package/package.json create mode 100644 test/integration/monorepo/packages/package/src/index.ts create mode 100644 test/integration/monorepo/packages/package/tsconfig.json create mode 100644 test/integration/monorepo/tsconfig.json diff --git a/test/integration.test.ts b/test/integration.test.ts index 3794cd5b..9342d8bf 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -19,6 +19,7 @@ const getPath = (filepath: string) => join(integrationTestDir, filepath) const testCases: { name: string dir?: string + skip?: boolean args?: string[] before?(dir: string): Promise | void expected( @@ -842,6 +843,16 @@ const testCases: { expect(stderr).toContain('./dist/foo.cjs') }, }, + { + name: 'ts-composite', + dir: 'monorepo/packages/package', + skip: true, + args: [], + async expected(dir) { + expect(await existsFile(join(dir, './dist/index.js'))).toBe(true) + expect(await existsFile(join(dir, './dist/index.d.ts'))).toBe(true) + }, + }, ] async function runBundle( @@ -875,8 +886,11 @@ async function runBundle( function runTests() { for (const testCase of testCases) { - const { name, args = [], expected, before } = testCase + const { name, args = [], expected, before, skip } = testCase const dir = getPath(testCase.dir ?? name) + if (skip) { + return + } test(`integration ${name}`, async () => { debug.log(`Command: bunchee ${args.join(' ')}`) if (before) { diff --git a/test/integration/monorepo/package.json b/test/integration/monorepo/package.json new file mode 100644 index 00000000..f436067e --- /dev/null +++ b/test/integration/monorepo/package.json @@ -0,0 +1,6 @@ +{ + "name": "monorepo", + "dependencies": { + "package": "link:./packages/package" + } +} diff --git a/test/integration/monorepo/packages/package/package.json b/test/integration/monorepo/packages/package/package.json new file mode 100644 index 00000000..7e9ed748 --- /dev/null +++ b/test/integration/monorepo/packages/package/package.json @@ -0,0 +1,5 @@ +{ + "name": "package", + "main": "./dist/index.js", + "types": "./dist/index.d.ts" +} diff --git a/test/integration/monorepo/packages/package/src/index.ts b/test/integration/monorepo/packages/package/src/index.ts new file mode 100644 index 00000000..6452c484 --- /dev/null +++ b/test/integration/monorepo/packages/package/src/index.ts @@ -0,0 +1,3 @@ +export function foo () { + return 'bar' +} diff --git a/test/integration/monorepo/packages/package/tsconfig.json b/test/integration/monorepo/packages/package/tsconfig.json new file mode 100644 index 00000000..50d1bbc2 --- /dev/null +++ b/test/integration/monorepo/packages/package/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "bundler" + } +} diff --git a/test/integration/monorepo/tsconfig.json b/test/integration/monorepo/tsconfig.json new file mode 100644 index 00000000..e47654b4 --- /dev/null +++ b/test/integration/monorepo/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "composite": true, + "incremental": true + }, + "references": [ + { + "path": "./packages/package" + } + ] +}