When using the declarationDir option with a nested path, npm build should output the bundled code in the dist folder, and the type declarations in the dist/types folder.
In 12.1.1, the command fails with the following error:
[!] (plugin typescript) RollupError: [plugin typescript] @rollup/plugin-typescript: Path of Typescript compiler option 'declarationDir' must be located inside the same directory as the Rollup 'file' option.
Additional Information
I tried different combinations of relative paths for both outDir and declarationDir, but none worked:
outDir: 'dist' and declarationDir: 'dist/types'
outDir: './dist' and declarationDir: 'dist/types'
outDir: 'dist' and declarationDir: './dist/types'
outDir: './dist' and declarationDir: './dist/types'
outDir: 'dist' and declarationDir: 'types'
outDir: './dist' and declarationDir: 'types'
outDir: 'dist' and declarationDir: './types'
outDir: './dist' and declarationDir: './types'
The only combination that works is using dist for both, but that defeats the purpose of having the types in a nested folder:
rollup-plugin-typescript
12.1.1
Expected Behavior
When using the
declarationDir
option with a nested path,npm build
should output the bundled code in thedist
folder, and the type declarations in thedist/types
folder.This was working in
12.1.0
, as seen here: https://stackblitz.com/edit/rollup-ts-afeykb?file=rollup.config.jsActual Behavior
In
12.1.1
, the command fails with the following error:Additional Information
I tried different combinations of relative paths for both
outDir
anddeclarationDir
, but none worked:outDir: 'dist'
anddeclarationDir: 'dist/types'
outDir: './dist'
anddeclarationDir: 'dist/types'
outDir: 'dist'
anddeclarationDir: './dist/types'
outDir: './dist'
anddeclarationDir: './dist/types'
outDir: 'dist'
anddeclarationDir: 'types'
outDir: './dist'
anddeclarationDir: 'types'
outDir: 'dist'
anddeclarationDir: './types'
outDir: './dist'
anddeclarationDir: './types'
The only combination that works is using
dist
for both, but that defeats the purpose of having the types in a nested folder:outDir: 'dist'
anddeclarationDir: 'dist'