Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/createRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export async function createRollupConfig(
compilerOptions: {
sourceMap: true,
declaration: true,
declarationDir: paths.appDist,
jsx: 'react',
},
},
Expand All @@ -165,9 +166,8 @@ export async function createRollupConfig(
},
},
check: !opts.transpileOnly,
useTsconfigDeclarationDir: Boolean(
tsconfigJSON?.compilerOptions?.declarationDir
),
// declarationDir is used internally above as a default
useTsconfigDeclarationDir: true,
}),
babelPluginTsdx({
exclude: 'node_modules/**',
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/build-default/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"module": "ESNext",
"lib": ["dom", "esnext"],
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"rootDir": "./src",
"strict": true,
Expand Down
18 changes: 17 additions & 1 deletion test/tests/tsdx-build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*/

const shell = require('shelljs');
const fs = require('fs-extra');

const util = require('../fixtures/util');

shell.config.silent = false;
Expand Down Expand Up @@ -42,6 +44,17 @@ describe('tsdx build', () => {
expect(lib.foo()).toBe('bar');
});

it('should create declarationMap files (*.d.ts.map) correctly', async () => {
util.setupStageWithFixture(stageName, 'build-default');

shell.exec('node ../dist/index.js build');

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

const dtsmap = await fs.readJSON('dist/index.d.ts.map');
expect(dtsmap.sources[0]).toBe('../src/index.ts');
});

it('should clean the dist directory before rebuilding', () => {
util.setupStageWithFixture(stageName, 'build-default');

Expand Down Expand Up @@ -102,7 +115,7 @@ describe('tsdx build', () => {
expect(code).toBe(0);
});

it('should use the declarationDir when set in tsconfig', () => {
it('should use the declarationDir when set in tsconfig', async () => {
util.setupStageWithFixture(stageName, 'build-withTsconfig');

const output = shell.exec('node ../dist/index.js build --format esm,cjs');
Expand All @@ -120,6 +133,9 @@ describe('tsdx build', () => {
expect(shell.test('-f', 'typings/index.d.ts')).toBeTruthy();
expect(shell.test('-f', 'typings/index.d.ts.map')).toBeTruthy();

const dtsmap = await fs.readJSON('typings/index.d.ts.map');
expect(dtsmap.sources[0]).toBe('../src/index.ts');

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

Expand Down