Skip to content

feat(oxlint-config)!: emit Vite declarations with tsrs - #278

Draft
jan-kubica wants to merge 2 commits into
mainfrom
feat/oxlint-config-declarations
Draft

jan-kubica wants to merge 2 commits into
mainfrom
feat/oxlint-config-declarations

Conversation

@jan-kubica

@jan-kubica jan-kubica commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Split out of #232, which carried this change after #233 was merged into its branch. Based on main, which now has #232's oxc-parser config reader.

  • declarationOnlyDts emits declarations with tsrs (one tsrs run after the bundle is written), replacing vite-plugin-dts and unplugin-dts. Consumers no longer need TypeScript 6.0.3 for the helper.
  • The helper reads a generated config that extends the package tsconfig and writes declarations only into build.outDir. The hook and context guards around the old third-party plugin are removed; the output check that leaves non-declaration files untouched stays.
  • Options shrink to include, exclude, entryRoot and compilerOptions.declarationMap: false. pathsToAliases, strictOutput and declarationOnly are rejected; tsconfig paths, compiler-option errors, inputs outside entryRoot and empty inputs fail the build.
  • The helper loads the tsrs API from tsrs/async.
  • The package's own build uses tsdown's tsrs declaration generator. The tsgo generator with a tsrs binary path only worked while TypeScript 7.0 came in through vite-plugin-dts.
  • Changeset: major for @stll/oxlint-config.

Review findings carried over from #232 (to address before merge)

  • publish-build-target-vite-dts-helper.ts:108 Generated tsconfig under the system temp dir loses package-local types resolution (["node"]/["bun"] resolve from temp ancestors, degrading declarations to any).
  • publish-build-target-vite-dts-helper.ts:108 A package tsconfig without files/include relies on the default **/*, which tsrs resolves from the temp dir, so valid packages fail with no inputs.
  • publish-build-target-vite-dts-helper.ts:136 A caller exclude replaces the default outDir exclusion, so Vite's written output (e.g. dist/index.js with allowJs) becomes a declaration input.
  • publish-build-target-vite-dts-helper.ts:158 With an explicit entryRoot, an empty input set (files: []) is not rejected and the build succeeds without declarations.
  • publish-build-target-vite-dts-helper.ts:157 Without entryRoot, rootDir should be derived from the source files the compiler emits, not from every parsed file name.
  • publish-build-target-vite-dts-helper.ts:181 Removing a leading CSS import shifts declaration lines while .d.ts.map keeps old positions; update the map or reject the combination.
  • publish-build-target-vite-dts-helper.ts:247 The emitted flag is never reset, so a second build (or a retry after a failed emit) with the same plugin instance skips declarations.
  • publish-build-target-vite-dts.ts:46 The public option type dropped string for include/exclude although the runtime still normalises it; keep string | readonly string[] at the boundary.
  • publish-build-target-vite-dts.test.ts:211 The outside-entryRoot test matches any Declaration emit failed; assert the specific error (TS6059 and the file).
  • scripts/check-publish-artifact-profiles.ts:86 The profile check accepts any one JavaScript file; require both index.js and index.cjs plus index.d.ts.
  • .changeset/declarations-with-tsrs.md:9 The "accepts only" option list omits the required directory option.
  • .changeset/declarations-with-tsrs.md:10 Tell consumers to remove or empty-override inherited paths mappings, since the helper checks the effective map.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

The helper loads the tsrs API from tsrs/async, its current entry point.
tsdown's tsgo generator only falls back to a tsrs binary path when
TypeScript 7.0 is installed, which came in through vite-plugin-dts.
With that dependency gone the build selects the tsrs generator
directly.
@jan-kubica
jan-kubica force-pushed the feat/oxlint-config-declarations branch from e6c6dc7 to 0743386 Compare November 18, 2026 10:54
@jan-kubica
jan-kubica changed the base branch from feat/publish-oxc-parse to main November 18, 2026 10:54
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

Successfully merging this pull request may close these issues.

1 participant