Skip to content
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
9 changes: 8 additions & 1 deletion packages/typescript/src/options/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,20 @@ export function validatePaths(
`@rollup/plugin-typescript: Path of Typescript compiler option '${dirProperty}' must be located inside Rollup 'dir' option.`
);
}
} else {
} else if (dirProperty === 'outDir') {
const fromTsDirToRollup = relative(compilerOptions[dirProperty]!, outputDir);
if (fromTsDirToRollup.startsWith('..')) {
context.error(
`@rollup/plugin-typescript: Path of Typescript compiler option '${dirProperty}' must be located inside the same directory as the Rollup 'file' option.`
);
}
} else {
const fromTsDirToRollup = relative(outputDir, compilerOptions[dirProperty]!);
if (fromTsDirToRollup.startsWith('..')) {
context.error(
`@rollup/plugin-typescript: Path of Typescript compiler option '${dirProperty}' must be located inside the same directory as the Rollup 'file' option.`
);
}
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions packages/typescript/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@ test.serial(
}
);

test.serial(
'ensures declarationDir is allowed in Rollup output directory when output.file is used',
async (t) => {
const bundle = await rollup({
input: 'fixtures/basic/main.ts',
plugins: [
typescript({
tsconfig: 'fixtures/basic/tsconfig.json',
declarationDir: 'fixtures/basic/dist/other',
declaration: true
})
],
onwarn
});

// this should not throw an error
await t.notThrowsAsync(() =>
getCode(bundle, { format: 'es', file: 'fixtures/basic/dist/index.js' }, true)
);
}
);

test.serial(
'ensures output files can be written to subdirectories within the tsconfig outDir',
async (t) => {
Expand Down