jsconfig ignored?
What happens and why it is wrong
I was struggling with generating JSDoc typings for a library using Microdundle. It generated index.d.ts but none of the imported files. The root issue was missing "include" : ["src"] (inspired by #211). I tried adding it to jsconfig.json after scouring issues here as well as in Microbundle and TSDX. I finally tried renaming to tsconfig.json and resolved my issue.
Suggested fix
Arguably this might belong in Microbundle if JSDoc typings aren't an intended use case for this plugin? Or just manually pass "jsconfig.json".
https://github.com/ezolenko/rollup-plugin-typescript2/blob/cffc4dae290e7b9f160e5472d48530a725213b61/src/parse-tsconfig.ts#L13-L17
const getConfig = (name) => tsModule.findConfigFile(pluginOptions.cwd, tsModule.sys.fileExists, name);
const fileName =
getConfig(pluginOptions.tsconfig) ||
// if the value was provided, but no file, fail hard (previously `failed to open undefined`)
(pluginOptions.tsconfig && throw new Error(`failed to open '${pluginOptions.tsconfig}'`)) ||
getConfig("jsconfig.json");
Environment
Versions
From package-lock.json (envinfo doesn't list nested dependencies):
npmPackages:
typescript: 4.5.5
rollup: 2.67.2
rollup-plugin-typescript2: 0.29.0
rollup.config.js
`rollup.config.js`:
https://github.com/developit/microbundle/blob/v0.14.2/src/index.js#L523-L556
tsconfig.json
`tsconfig.json`:
include (described above) is the only key in tsconfig.json.
package.json
`package.json`:
npmPackages:
microbundle: ^0.14.2 => 0.14.2
plugin output with verbosity 3
plugin output with verbosity 3:
Good find! I wrote TSDX's tsconfig parsing in https://github.com/jaredpalmer/tsdx/pull/489 , which borrowed some code from here actually (I was the solo maintainer of and only active contributor to TSDX for over a year). I've contributed some fixes etc here too. And I was looking to extract some of this similar code into a tiny package for parsing tsconfigs actually, mainly because the TS API is really non-trivial and opaque to use (see that PR for some details of how I had to figure out how to parse with it).
Or just manually pass "jsconfig.json".
The tsconfig option could probably just be set to ./jsconfig.json for this to work here.
I'm not a maintainer here, but your proposal sounds more or less reasonable to me. I would probably make several stylistic changes, throw an error if neither exists, and use a default value if it's currently undefined so that the error is readable.
That being said, since this plugin doesn't set defaults for tsconfig, it may indeed make more sense for downstream packages to implement support for this.
I also wonder if just using a tsconfig with allowJs: true is enough for most users and jsconfig support should otherwise be built into the TS API. I'm actually a little surprised it's not reading a jsconfig when pluginOptions.tsconfig is undefined