-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
declaration maps (*.d.ts.map) have incorrect relative paths in sources
unless declarationDir
is set
#204
Comments
I think it relates to this line: rollup-plugin-typescript2/src/get-options-overrides.ts Lines 32 to 33 in ac82124
The line above is when declarations are not requested at all. That cwd should arguably be rollup output folder. Problem with that is rollup can have multiple output folders configured, and when not using By setting |
We can probably set declarationDir to first rollup output folder in this case and get a significant number of cases right instead of none... |
Note: If it is not set both tsconfig's `declarationDir` and rollup.config's `useTsconfigDeclarationDir`, distribution d.ts.map is incorrect related issue: ezolenko/rollup-plugin-typescript2#204
Note: If it is not set both tsconfig's `declarationDir` and rollup.config's `useTsconfigDeclarationDir`, distribution d.ts.map is incorrect related issue: ezolenko/rollup-plugin-typescript2#204
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.ts
as input and outputs./dist/index.js
,./dist/index.d.ts
, and ifdeclarationMap
istrue
,./dist/index.d.ts.map
, which has asources
attribute.declarationDir
is not set,sources
will incorrectly point toindex.ts
declarationDir
is set to./dist
,sources
will correctly point to../src/index.ts
.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 beforeemitFile
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
rollup.config.js
The only difference is what's listed above (
useTsconfigDeclarationDir
anddeclarationDir
), but current, non-trivial config is heretsconfig.json
declarationDir
is 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.
The text was updated successfully, but these errors were encountered: