Skip to content
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

Feature Request: Disable parsing local tsconfig #300

Open
1 of 3 tasks
huozhi opened this issue Jan 31, 2024 · 0 comments
Open
1 of 3 tasks

Feature Request: Disable parsing local tsconfig #300

huozhi opened this issue Jan 31, 2024 · 0 comments

Comments

@huozhi
Copy link

huozhi commented Jan 31, 2024

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

  • 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.

if (!configByPath.has(cacheKey)) {
logCache("miss", cacheKey);
const configPath = overrideConfigPath
? path.resolve(process.cwd(), overrideConfigPath)
: ts.findConfigFile(dirName, ts.sys.fileExists);
if (!configPath) {
return { dtsFiles, dirName, compilerOptions };
}
let inputDirName = dirName;
dirName = path.dirname(configPath);
const { config, error } = ts.readConfigFile(configPath, ts.sys.readFile);

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant