Skip to content

Commit

Permalink
fix: types declaration default location (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
igordanchenko committed Jan 14, 2022
1 parent ad7d32f commit 2d6931e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/createRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export async function createRollupConfig(
.join('.');

const tsCompilerOptions = typescriptCompilerOptions(opts.tsconfig);
const typesRollupEnabled = isTypesRollupEnabled(appPackageJson);
const typesRollupEnabled =
opts.rollupTypes && isTypesRollupEnabled(appPackageJson);
const declarationDir =
typescriptCompilerOptions(opts.tsconfig).declarationDir ||
(typesRollupEnabled ? path.join('dist', 'types') : undefined);
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface DtsOptions extends SharedOpts {
writeMeta?: boolean;
// Only transpile, do not type check (makes compilation faster)
transpileOnly?: boolean;
// Is rolling up types?
rollupTypes?: boolean;
}

export interface PackageJson {
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/dts-build-withTypesRollup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ describe('dts build :: types rollup', () => {
expect(output.code).toBe(0);
});

it('should not run by default', () => {
it('should not run by default and types should be output into the dist root', () => {
const output = execWithCache('node ../dist/index.js build');

expect(shell.test('-f', 'dist/types/index.d.ts')).toBeTruthy();
expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy();

expect(shell.test('-f', 'dist/types/foo/foo.d.ts')).toBeTruthy();
expect(shell.test('-f', 'dist/types/bar/bar.d.ts')).toBeTruthy();
expect(shell.test('-f', 'dist/foo/foo.d.ts')).toBeTruthy();
expect(shell.test('-f', 'dist/bar/bar.d.ts')).toBeTruthy();

expect(output.code).toBe(0);
});
Expand Down

0 comments on commit 2d6931e

Please sign in to comment.