rollup-plugin-dts icon indicating copy to clipboard operation
rollup-plugin-dts copied to clipboard

Feature Request: Disable parsing local tsconfig

Open huozhi opened this issue 1 year ago • 0 comments

When rollup-plugin-dts cannot find the tsconfig path, then it will start looking for the local tsconfig.json and parse it. But sometimes the final result of parsing can not be correct. For instance

If users gave incremental: true in compiler options but didn't specify tsBuildInfoFile cause they expect that will be filled with default value from typescript, which is .tsbuildinfo. Usually types generation don't need to pick up those project or compiler cache related configs such as composite or incremental,

Checklist

  • [x] I can reproduce this issue when running this plugin on its own. Other plugins, such as node-resolve are known to cause issues.
  • [ ] I am running this plugin on .d.ts files generated by TypeScript. The plugin can consume .ts and even .js files (with allowJs: true), but this is known to cause issues.
  • [ ] This issue is not related to rolling up @types. The plugin ignores these by default, unless respectExternal is set. @types can contain hand-crafted code which is known to cause issues.

Code Snipped

Here in the plugin, when it failed to find the local config, it went to search for the local tsconfig and parse it.

https://github.com/Swatinem/rollup-plugin-dts/blob/fea09d8271572af03c9460b2055cb0c1439fab41/src/program.ts#L66-L76

Error Message

Failed with TS error

error TS5074: Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified.

Expected

I wonder if we can just have an value on tsconfig that can disable this picking up local config behavior. Such as tsconfig: false that will only use the overriden compiler options without merging with local tsconfig. That would be much easier for generating types since it can rely on a fixed compiler options config no matter how users config it.

huozhi avatar Jan 31 '24 11:01 huozhi