From 5ea8fe9b080a73cdfdbe9da5b2fcff21a0d80e7d Mon Sep 17 00:00:00 2001 From: Victor LE DANTEC Date: Fri, 13 Sep 2024 11:28:38 +0200 Subject: [PATCH 1/4] fix: pass custom tsconfig to rollup-plugin-dts --- src/utils/get-rollup-configs.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/get-rollup-configs.ts b/src/utils/get-rollup-configs.ts index ce254c5..7d946e7 100644 --- a/src/utils/get-rollup-configs.ts +++ b/src/utils/get-rollup-configs.ts @@ -59,6 +59,7 @@ const getConfig = { ), resolveTypescriptMjsCts(), dts.default({ + tsconfig: tsconfig?.path, respectExternal: true, /** From 224476e1b4220e3ea6048310940f3aae803d2593 Mon Sep 17 00:00:00 2001 From: Victor LE DANTEC Date: Fri, 13 Sep 2024 15:46:16 +0200 Subject: [PATCH 2/4] test: pass custom tsconfig to rollup-plugin-dts --- tests/specs/builds/typescript.ts | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/specs/builds/typescript.ts b/tests/specs/builds/typescript.ts index 4e7f7df..39bf85c 100644 --- a/tests/specs/builds/typescript.ts +++ b/tests/specs/builds/typescript.ts @@ -215,5 +215,40 @@ export default testSuite(({ describe }, nodePath: string) => { expect(pkgrollProcess.exitCode).toBe(1); // expect(pkgrollProcess.stderr).toMatch('Cannot resolve tsconfig at path:'); }); + + test('should pass custom tsconfig.json to dts module', async () => { + await using fixture = await createFixture({ + ...installTypeScript, + src: { + 'index.ts': 'export default () => "foo";', + }, + 'package.json': createPackageJson({ + main: './dist/index.js', + types: './dist/index.d.ts', + }), + 'tsconfig.json': createTsconfigJson({ + compilerOptions: { + incremental: true, + }, + }), + 'tsconfig.build.json': createTsconfigJson({ + compilerOptions: { + incremental: false, + }, + }), + }); + + const pkgrollProcess = await pkgroll([ + '--env.NODE_ENV=test', + '--tsconfig=tsconfig.build.json', + ], { + cwd: fixture.path, + nodePath, + reject: false, + }); + + expect(pkgrollProcess.exitCode).toBe(0); + expect(pkgrollProcess.stderr).toBe(''); + }); }); }); From a796a96312b17cc544eb70d9b88df7338a6ebe4f Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 20 Nov 2024 08:37:44 +0900 Subject: [PATCH 3/4] wip --- tests/specs/builds/typescript.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/specs/builds/typescript.ts b/tests/specs/builds/typescript.ts index 39bf85c..9580ba4 100644 --- a/tests/specs/builds/typescript.ts +++ b/tests/specs/builds/typescript.ts @@ -217,23 +217,27 @@ export default testSuite(({ describe }, nodePath: string) => { }); test('should pass custom tsconfig.json to dts module', async () => { - await using fixture = await createFixture({ + const fixture = await createFixture({ ...installTypeScript, src: { - 'index.ts': 'export default () => "foo";', + 'index.tsx': 'export default () => (
hi
);', }, 'package.json': createPackageJson({ main: './dist/index.js', - types: './dist/index.d.ts', + dependencies: { + working: '*', + }, }), 'tsconfig.json': createTsconfigJson({ compilerOptions: { - incremental: true, + jsx: 'react-jsx', + jsxImportSource: 'not-working', }, }), 'tsconfig.build.json': createTsconfigJson({ compilerOptions: { - incremental: false, + jsx: 'react-jsx', + jsxImportSource: 'working', }, }), }); @@ -249,6 +253,9 @@ export default testSuite(({ describe }, nodePath: string) => { expect(pkgrollProcess.exitCode).toBe(0); expect(pkgrollProcess.stderr).toBe(''); + + const code = await fixture.readFile('dist/index.js', 'utf8'); + expect(code).toMatch('working'); }); }); }); From e200519b6de16980c2f560d8d2dffc500a68c61f Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 20 Nov 2024 08:55:48 +0900 Subject: [PATCH 4/4] wip --- tests/specs/builds/typescript.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/specs/builds/typescript.ts b/tests/specs/builds/typescript.ts index 9580ba4..4aa23d9 100644 --- a/tests/specs/builds/typescript.ts +++ b/tests/specs/builds/typescript.ts @@ -231,7 +231,7 @@ export default testSuite(({ describe }, nodePath: string) => { 'tsconfig.json': createTsconfigJson({ compilerOptions: { jsx: 'react-jsx', - jsxImportSource: 'not-working', + jsxImportSource: 'breaking', }, }), 'tsconfig.build.json': createTsconfigJson({