Repository navigation
feat(oxlint-config)!: emit Vite declarations with tsrs - #233
Conversation
The declaration-only Vite helper runs tsrs once after the bundle is written. It reads a generated config that extends the package tsconfig and emits declarations only into build.outDir. Consumers no longer install vite-plugin-dts, unplugin-dts or TypeScript 6.0.3. Because the helper no longer wraps a third-party plugin, the hook and context guards around it are deleted. The output check that leaves non-declaration files untouched stays. Options shrink to include, exclude, entryRoot and compilerOptions.declarationMap=false. compilerOptions.paths fails the build, because declarations keep import specifiers as written.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 72f46b332b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const scratch = mkdtempSync(path.join(tmpdir(), "stll-declarations-")); | ||
| const config = path.join(scratch, "tsconfig.json"); |
There was a problem hiding this comment.
Preserve package-local type resolution in the generated config
When the package tsconfig specifies compilerOptions.types without explicit typeRoots (for example, types: ["node"]), placing the generated config in a separate temporary directory changes where those type packages are resolved: resolution starts from the temporary config rather than the package. Extending the original config does not preserve that lookup location. A package-local ambient type fixture emits the correct structural type with its original config but reports missing type definitions and emits any through the temporary extending config. Since type diagnostics become warnings here, this can silently publish degraded declarations. Keep the generated config package-local or explicitly preserve the original type-resolution roots.
Useful? React with 👍 / 👎.
The declaration-only Vite helper runs tsrs once after the bundle is written. It reads a generated config that extends the package tsconfig and emits declarations only into build.outDir. Consumers no longer install vite-plugin-dts, unplugin-dts or TypeScript 6.0.3. Because the helper no longer wraps a third-party plugin, the hook and context guards around it are deleted. The output check that leaves non-declaration files untouched stays. Options shrink to include, exclude, entryRoot and compilerOptions.declarationMap=false. compilerOptions.paths fails the build, because declarations keep import specifiers as written.
Stacked on #232.
Summary
declarationOnlyDtsemits declarations with tsrs, which is already a dependency of@stll/oxlint-config. It runs once inwriteBundle(post), using a generated config that extends the packagetsconfig.jsonwithemitDeclarationOnly,outDirset tobuild.outDir, the helper's include/exclude, androotDirset toentryRoot.vite-plugin-dts5.1.2,unplugin-dts1.1.2 or TypeScript 6.0.3. They also leave this package's devDependencies, which removestypescript@7.0.2from the lockfile.build.outDirmust be byte-identical after the emit.entryRoot, no inputs, andcompilerOptions.pathsfail the build.include,exclude,entryRootandcompilerOptions.declarationMap: false. The CI profile fixture installs Vite only and checks that no TypeScript or declaration plugin is resolvable.Declaration parity
I built five corpora with the old helper (vite-plugin-dts + TypeScript 6.0.3) and the new one, then diffed the emitted
.d.tsfiles: a probe package plus this repo'stime,test-kit,oxlint-pluginandoxlint-configsources. 122 declaration files exist in both builds: 65 are byte-identical and 57 differ. The new build adds 2 files. Every difference falls into one of these groups:typemodifiers dropped,{ default as x }. tsrs keeps TypeScript's own form.import("...")types.allowJsJavaScript fixtures insideinclude. vite-plugin-dts skipped these.Doc comments are kept, and no declared type changes.
Checks
bun testonpublish-build-target-vite-dts.test.ts(real tsrs emits),publish-build-target-vite.test.tsandentry-graph.test.tsbun checkfor the package,check:publish-contract,check:toolchain, oxlint,bun fmt --checkon the changed filesChangeset: major. Configs that set
pathsToAliases,strictOutputordeclarationOnlynow fail, configs with tsconfigpathsnow fail, and the declaration text changes as listed above.