Skip to content

Commit

Permalink
fix: use custom tsconfig when generating dts (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
uinz authored Oct 25, 2024
1 parent 9f1195f commit 73559f8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/utils/get-rollup-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const getConfig = {
module: ts.default.ModuleKind.Preserve,
moduleResolution: ts.default.ModuleResolutionKind.Bundler,
},
tsconfig: tsconfig?.path,
}) as Plugin,
],
output: [] as unknown as Output,
Expand Down
32 changes: 32 additions & 0 deletions tests/specs/builds/output-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,37 @@ export default testSuite(({ describe }, nodePath: string) => {
expect(types).toMatch('\'dep-a\'');
expect(types).toMatch('.data');
});

test('custom tsconfig.json path', async () => {
await using fixture = await createFixture({
...packageFixture({
installTypeScript: true,
installReact: true,
}),
'package.json': createPackageJson({
types: './dist/component.d.ts',
peerDependencies: {
react: '*',
},
}),
'tsconfig.custom.json': createTsconfigJson({
compilerOptions: {
jsx: 'react-jsx',
},
}),
});

const pkgrollProcess = await pkgroll(['-p', 'tsconfig.custom.json'], {
cwd: fixture.path,
nodePath,
});

expect(pkgrollProcess.exitCode).toBe(0);
expect(pkgrollProcess.stderr).toBe('');

const content = await fixture.readFile('dist/component.d.ts', 'utf8');
expect(content).toMatch('declare const Component: () => react_jsx_runtime.JSX.Element');
expect(content).toMatch('export { Component }');
});
});
});

0 comments on commit 73559f8

Please sign in to comment.