Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use custom tsconfig when generating dts #100

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/utils/get-rollup-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
) => {
const [dts, ts] = await Promise.all([
import('rollup-plugin-dts'),
import('typescript'),

Check warning on line 48 in src/utils/get-rollup-configs.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Maximum number of dependencies (15) exceeded
]);
return {
input: [] as string[],
Expand Down Expand Up @@ -80,6 +80,7 @@
module: ts.default.ModuleKind.Preserve,
moduleResolution: ts.default.ModuleResolutionKind.Bundler,
},
tsconfig: tsconfig?.path,
}) as Plugin,
],
output: [] as unknown as Output,
Expand Down Expand Up @@ -168,7 +169,7 @@
aliases: AliasMap,
packageJson: PackageJson,
tsconfig: TsConfigResult | null,
) => {

Check warning on line 172 in src/utils/get-rollup-configs.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Async arrow function has too many parameters (7). Maximum allowed is 5
const executablePaths = inputs
.filter(({ exportEntry }) => exportEntry.isExecutable)
.map(({ exportEntry }) => exportEntry.outputPath);
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 }');
});
});
});
Loading