From 288a6883f9248e55944694c1de754f0bf9c12a98 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 6 Nov 2024 16:40:24 -0800 Subject: [PATCH 1/3] fix: dual entry --- test/integration/dual-entry/index.test.ts | 20 ++++++++++++++++++++ test/integration/dual-entry/package.json | 10 ++++++++++ test/integration/dual-entry/src/a.ts | 1 + test/integration/dual-entry/src/a.workerd.ts | 1 + test/integration/dual-entry/src/a/shared.ts | 1 + 5 files changed, 33 insertions(+) create mode 100644 test/integration/dual-entry/index.test.ts create mode 100644 test/integration/dual-entry/package.json create mode 100644 test/integration/dual-entry/src/a.ts create mode 100644 test/integration/dual-entry/src/a.workerd.ts create mode 100644 test/integration/dual-entry/src/a/shared.ts diff --git a/test/integration/dual-entry/index.test.ts b/test/integration/dual-entry/index.test.ts new file mode 100644 index 00000000..8ac104e7 --- /dev/null +++ b/test/integration/dual-entry/index.test.ts @@ -0,0 +1,20 @@ +import fs from 'fs' +import { assertFilesContent, createIntegrationTest } from '../utils' + +describe('integration tsconfig-override', () => { + it('should not generate js types paths if not specified', async () => { + await createIntegrationTest( + { + directory: __dirname, + }, + async ({ dir }) => { + assertFilesContent(dir, { + './dist/subpath/nested.js': 'subpath/nested', + './dist/subpath/nested.cjs': 'subpath/nested', + }) + const subpathTypes = await import(`${dir}/dist/index.js`) + expect(fs.existsSync(subpathTypes)).toBe(false) + }, + ) + }) +}) diff --git a/test/integration/dual-entry/package.json b/test/integration/dual-entry/package.json new file mode 100644 index 00000000..36620395 --- /dev/null +++ b/test/integration/dual-entry/package.json @@ -0,0 +1,10 @@ +{ + "name": "undefined-types-paths", + "type": "module", + "exports": { + "./a": { + "workerd": "./dist/a.workerd.js", + "import": "./dist/a.js" + } + } +} diff --git a/test/integration/dual-entry/src/a.ts b/test/integration/dual-entry/src/a.ts new file mode 100644 index 00000000..9c2840e2 --- /dev/null +++ b/test/integration/dual-entry/src/a.ts @@ -0,0 +1 @@ +export { internal } from './a/shared' diff --git a/test/integration/dual-entry/src/a.workerd.ts b/test/integration/dual-entry/src/a.workerd.ts new file mode 100644 index 00000000..9c2840e2 --- /dev/null +++ b/test/integration/dual-entry/src/a.workerd.ts @@ -0,0 +1 @@ +export { internal } from './a/shared' diff --git a/test/integration/dual-entry/src/a/shared.ts b/test/integration/dual-entry/src/a/shared.ts new file mode 100644 index 00000000..b13d8e9f --- /dev/null +++ b/test/integration/dual-entry/src/a/shared.ts @@ -0,0 +1 @@ +export const internal = 'a' From 6e86746dde4e0c8b78d673f9257c0f1acde9d01b Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Sat, 23 Nov 2024 20:40:48 +0100 Subject: [PATCH 2/3] disable test --- test/integration/dual-entry/index.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/dual-entry/index.test.ts b/test/integration/dual-entry/index.test.ts index 8ac104e7..4cc4cb15 100644 --- a/test/integration/dual-entry/index.test.ts +++ b/test/integration/dual-entry/index.test.ts @@ -1,7 +1,8 @@ import fs from 'fs' import { assertFilesContent, createIntegrationTest } from '../utils' -describe('integration tsconfig-override', () => { +// FIXME: should error if there're duplicate entries +describe.skip('integration tsconfig-override', () => { it('should not generate js types paths if not specified', async () => { await createIntegrationTest( { From 2f6b1b4e568d6f704754f1db327e5dc9c0c1ea5a Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Sun, 24 Nov 2024 18:53:01 +0100 Subject: [PATCH 3/3] update test --- test/integration/dual-entry/index.test.ts | 21 ------------------- .../index.test.ts | 17 +++++++++++++++ .../package.json | 0 .../src/a.ts | 0 .../src/a.workerd.ts | 0 .../src/a/shared.ts | 0 6 files changed, 17 insertions(+), 21 deletions(-) delete mode 100644 test/integration/dual-entry/index.test.ts create mode 100644 test/integration/duplicate-entries-partial-specified/index.test.ts rename test/integration/{dual-entry => duplicate-entries-partial-specified}/package.json (100%) rename test/integration/{dual-entry => duplicate-entries-partial-specified}/src/a.ts (100%) rename test/integration/{dual-entry => duplicate-entries-partial-specified}/src/a.workerd.ts (100%) rename test/integration/{dual-entry => duplicate-entries-partial-specified}/src/a/shared.ts (100%) diff --git a/test/integration/dual-entry/index.test.ts b/test/integration/dual-entry/index.test.ts deleted file mode 100644 index 4cc4cb15..00000000 --- a/test/integration/dual-entry/index.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import fs from 'fs' -import { assertFilesContent, createIntegrationTest } from '../utils' - -// FIXME: should error if there're duplicate entries -describe.skip('integration tsconfig-override', () => { - it('should not generate js types paths if not specified', async () => { - await createIntegrationTest( - { - directory: __dirname, - }, - async ({ dir }) => { - assertFilesContent(dir, { - './dist/subpath/nested.js': 'subpath/nested', - './dist/subpath/nested.cjs': 'subpath/nested', - }) - const subpathTypes = await import(`${dir}/dist/index.js`) - expect(fs.existsSync(subpathTypes)).toBe(false) - }, - ) - }) -}) diff --git a/test/integration/duplicate-entries-partial-specified/index.test.ts b/test/integration/duplicate-entries-partial-specified/index.test.ts new file mode 100644 index 00000000..8d983f12 --- /dev/null +++ b/test/integration/duplicate-entries-partial-specified/index.test.ts @@ -0,0 +1,17 @@ +import { createIntegrationTest, getFileNamesFromDirectory } from '../utils' + +describe('integration duplicate-entries-partial-specified', () => { + it('should not generate js types paths if not specified', async () => { + await createIntegrationTest( + { + directory: __dirname, + }, + async ({ distDir }) => { + expect(await getFileNamesFromDirectory(distDir)).toEqual([ + 'a.js', + 'a.workerd.js', + ]) + }, + ) + }) +}) diff --git a/test/integration/dual-entry/package.json b/test/integration/duplicate-entries-partial-specified/package.json similarity index 100% rename from test/integration/dual-entry/package.json rename to test/integration/duplicate-entries-partial-specified/package.json diff --git a/test/integration/dual-entry/src/a.ts b/test/integration/duplicate-entries-partial-specified/src/a.ts similarity index 100% rename from test/integration/dual-entry/src/a.ts rename to test/integration/duplicate-entries-partial-specified/src/a.ts diff --git a/test/integration/dual-entry/src/a.workerd.ts b/test/integration/duplicate-entries-partial-specified/src/a.workerd.ts similarity index 100% rename from test/integration/dual-entry/src/a.workerd.ts rename to test/integration/duplicate-entries-partial-specified/src/a.workerd.ts diff --git a/test/integration/dual-entry/src/a/shared.ts b/test/integration/duplicate-entries-partial-specified/src/a/shared.ts similarity index 100% rename from test/integration/dual-entry/src/a/shared.ts rename to test/integration/duplicate-entries-partial-specified/src/a/shared.ts