-
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
Runtime error when using as configPlugin
with "declarationMap": true
#310
Comments
- fancy source maps for declarations - apparently I left these out of `ts-library-base` so they didn't get copied here either - but most of my tsconfig there was copied too, so I suspect I left it out either because of @wessberg/rollup-plugin-ts's bugs with it or because TSDX previously had bugs with it - c.f. ezolenko/rollup-plugin-typescript2#221 and the worse downstream version I had written first: jaredpalmer/tsdx#488 - Unfortunately I did encounter a small error with declaration maps when using rpts2 as a configPlugin, due to an unexpected edge case in code I wrote myself in the above PR - wrote up an issue for it and will probably PR it myself too: ezolenko/rollup-plugin-typescript2#310 - as a workaround, I wrote a small `tsconfig.rollup.json` to be used with rpts2 as a configPlugin that disables `declarationMap` - and also adds some optimizations over my base tsconfig - took me a bit to figure out how to use options with configPlugins, as that was one of the reasons I didn't use @rollup/plugin-babel as the configPlugin - I still can't get it to read my `babel.config.js` even with options as it has no option for this (it auto-detects it) :/
- fancy source maps for declarations - apparently I left these out of `ts-library-base` so they didn't get copied here either - but most of my tsconfig there was copied too, so I suspect I left it out either because of @wessberg/rollup-plugin-ts's bugs with it or because TSDX previously had bugs with it - c.f. ezolenko/rollup-plugin-typescript2#221 and the worse downstream version I had written first: jaredpalmer/tsdx#488 - Unfortunately I did encounter a small error with declaration maps when using rpts2 as a configPlugin, due to an unexpected edge case in code I wrote myself in the above PR - wrote up an issue for it and will probably PR it myself too: ezolenko/rollup-plugin-typescript2#310 - as a workaround, I wrote a small `tsconfig.rollup.json` to be used with rpts2 as a configPlugin that disables `declarationMap` - and also adds some optimizations over my base tsconfig - took me a bit to figure out how to use options with configPlugins, as that was one of the reasons I didn't use @rollup/plugin-babel as the configPlugin - I still can't get it to read my `babel.config.js` even with options as it has no option for this (it auto-detects it) :/
Does this work if you set |
As expected (since the erroring code is in the Think it would still be good to get a real fix in as this is an actual unexpected edge case that my code didn't handle |
TypeError: The "from" argument must be of type string. Received undefined
when using as configPlugin
with "declarationMap": true
configPlugin
with "declarationMap": true
Released in 0.32.0 🎉 Double-checked that the release works in one of my libraries as well 🙂 |
What happens and why it is wrong
A runtime error occurs when your
tsconfig.json
has"declarationMap": true
and you use this plugin as aconfigPlugin
.Per the error below, it occurs on this line in the code. Specifically, it appears that
declarationDir
isundefined
because in the case of aconfigPlugin
, Rollup'soutput
isn't set what-so-ever, sooutput.file
andoutput.dir
are bothundefined
(see below for verbosity that verifies this).Ironically, I actually wrote this code myself in #221 so I could write a PR to fix this myself. I think a default
declarationDir
equivalent tocwd
would probably suffice for this -- let me know if you think a different solution makes sense, otherwise I could write that up pretty quickly.To be specific, rpts2 only errors when
declarationMap
is turned on, everything else doesn't seem to be impacted, so things likeemitFile
etc still work when used as aconfigPlugin
.Current workaround is to disable
declarationMap
intsconfig
(ortsconfigOverrides
) specifically when using as aconfigPlugin
only.Error:
Environment
Versions
:rollup.config.ts
My rollup config actually isn't relevant as I'm actually not using rpts2 in the rollup config, just for parsing the config itself (as I wrote it in TS)
:tsconfig.json
(slightly simplified version as I actually have multiple tsconfigs that extend each other)
:package.json
Think the
envinfo
output above is good enough; I've found the error in any case.plugin output with verbosity 3
:The text was updated successfully, but these errors were encountered: