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; |
or in
|
const relativePath = relative(pluginOptions.cwd, fileName); |
but I'm not sure. Also not sure if this is related to
#136 or not.
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 to index.ts
- When
declarationDir is set to ./dist, sources will correctly point to ../src/index.ts.
- (with
useTsconfigDeclarationDir: true ofc)
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
TSDX @ master
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.
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 inrollup-plugin-typescript2/src/get-options-overrides.ts
Line 31 in ac82124
rollup-plugin-typescript2/src/index.ts
Line 364 in df241da
The tl;dr on those related issues is that TSDX takes
./src/index.tsas input and outputs./dist/index.js,./dist/index.d.ts, and ifdeclarationMapistrue,./dist/index.d.ts.map, which has asourcesattribute.declarationDiris not set,sourceswill incorrectly point toindex.tsdeclarationDiris set to./dist,sourceswill correctly point to../src/index.ts.useTsconfigDeclarationDir: trueofc)But in both cases, whether
declarationDiris set to./distor not, everything gets output to./distvia Rollup config.If I'm understanding the code correctly, this is because the TS Language Service isn't creating the files when
declarationDirisn't set, and so the relative paths are generated incorrectly beforeemitFileis 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
TSDX @ master
Versions
rollup.config.js
The only difference is what's listed above (
useTsconfigDeclarationDiranddeclarationDir), but current, non-trivial config is heretsconfig.json
declarationDiris the only relevant one but here's a fixturepackage.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.