-
Notifications
You must be signed in to change notification settings - Fork 70
Description
What happens and why it is wrong
This comes from downstream TSDX at jaredpalmer/tsdx#479 (and jaredpalmer/tsdx#135), which I fixed in jaredpalmer/tsdx#488 by adding a declarationDir
, but I'm not sure if this isn't just a bug here. I believe the potential bug is either in
overrides.declarationDir = undefined; |
rollup-plugin-typescript2/src/index.ts
Line 364 in df241da
const relativePath = relative(pluginOptions.cwd, fileName); |
The tl;dr on those related issues is that TSDX takes ./src/index.ts
as input and outputs ./dist/index.js
, ./dist/index.d.ts
, and if declarationMap
is true
, ./dist/index.d.ts.map
, which has a sources
attribute.
- The problem is that when
declarationDir
is not set,sources
will incorrectly point toindex.ts
- When
declarationDir
is set to./dist
,sources
will correctly point to../src/index.ts
.- (with
useTsconfigDeclarationDir: true
ofc)
- (with
But in both cases, whether declarationDir
is set to ./dist
or not, everything gets output to ./dist
via Rollup config.
If I'm understanding the code correctly, this is because the TS Language Service isn't creating the files when declarationDir
isn't set, and so the relative paths are generated incorrectly before emitFile
is called.
So that seems like a bug here, but maybe I'm missing something or its not fixable without setting declarationDir
, sorry if that's the case 😅
Environment
Versions
- typescript: 3.7.5
- rollup: 1.27.8
- rollup-plugin-typescript2: 0.26.0
rollup.config.js
The only difference is what's listed above (useTsconfigDeclarationDir
and declarationDir
), but current, non-trivial config is here
tsconfig.json
declarationDir
is the only relevant one but here's a fixture
package.json
Probably not relevant but here
plugin output with verbosity 3
No errors, so I don't think it's relevant? Can run this on a fixture if needed.