[x] yes (bugfixes and features will not be merged without tests)
[ ] no
Breaking Changes?
[ ] yes (breaking changes will not be merged unless absolutely necessary)
[x] no
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
Currently, when output.file is specified instead of output.dir, the filename for emitting declaration files with this.emitFile is resolved incorrectly. This means that given a declarationDir that is outside of the bundle output directory (which is output.dir || dirname(output.file!)), the declarations will still be generated inside the bundle, albeit in a location not actually matching declarationDir that does not respect the absolute file path generated by typescript.
Whereas when using output.dir, declarationDir is actually validated and filenames for declarations are resolved correctly.
For example, with output.file = 'some-path/index.js' and declarationDir = 'types', the declaration files will be generated at some-path/types/index.d.ts, instead of types/index.d.ts which is the correct location (but invalid as it would be output the bundle directory). When output.dir = 'some-path' is used instead, validation fails as expected.
This can be fixed by just using dirname(output.file) in place of output.dir when output.file is specified, and including a validation check that declarationDir is valid when using output.file.
Rollup Plugin Name:
@rollup/plugin-typescript
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
Currently, when
output.file
is specified instead ofoutput.dir
, the filename for emitting declaration files withthis.emitFile
is resolved incorrectly. This means that given adeclarationDir
that is outside of the bundle output directory (which isoutput.dir || dirname(output.file!)
), the declarations will still be generated inside the bundle, albeit in a location not actually matchingdeclarationDir
that does not respect the absolute file path generated by typescript.Whereas when using
output.dir
,declarationDir
is actually validated and filenames for declarations are resolved correctly.For example, with
output.file = 'some-path/index.js'
anddeclarationDir = 'types'
, the declaration files will be generated atsome-path/types/index.d.ts
, instead oftypes/index.d.ts
which is the correct location (but invalid as it would be output the bundle directory). Whenoutput.dir = 'some-path'
is used instead, validation fails as expected.This can be fixed by just using
dirname(output.file)
in place ofoutput.dir
whenoutput.file
is specified, and including a validation check thatdeclarationDir
is valid when usingoutput.file
.