Skip to content

feat(dts)!: enable declaration extension redirects by default - #1784

Merged
Timeless0911 merged 2 commits into
mainfrom
david/feat-dts-extension-default
Jul 22, 2026
Merged

Timeless0911 merged 2 commits into
mainfrom
david/feat-dts-extension-default

Conversation

@Timeless0911

Copy link
Copy Markdown
Contributor

Summary

  • Enable redirect.dts.extension by default so declaration imports use runtime JavaScript extensions without extra configuration.
  • Breaking change: declaration import specifiers may now gain or replace extensions; set redirect.dts.extension to false to preserve the previous behavior.
  • Document path-mapping and CommonJS interop caveats, and cover tsc, tsgo, and isolated declaration outputs.

Related Links

Closes #1733

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

BREAKING CHANGE: Declaration import paths now use runtime JavaScript extensions by default. Set `redirect.dts.extension` to `false` to preserve existing specifiers.
Copilot AI review requested due to automatic review settings July 22, 2026 11:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 530dc8947a

ℹ️ 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".

Comment thread packages/plugin-dts/src/index.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables redirect.dts.extension by default so generated declaration files prefer explicit runtime JavaScript extensions (e.g. .js, .mjs) without requiring extra configuration, aligning better with Node16/NodeNext-style resolution.

Changes:

  • Switch the default for declaration extension redirection from false to true across core/plugin defaults and type docs.
  • Update integration tests and snapshots to expect redirected .js specifiers by default, and adjust the explicit “extension: false” cases accordingly.
  • Expand the redirect docs (EN/ZH) with caveats for paths/dts.alias path mapping and ESM/CJS declaration interop.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/docs/zh/config/lib/redirect.mdx Update default to true and add caveats/notes for redirect.dts.extension.
website/docs/en/config/lib/redirect.mdx Update default to true and add caveats/notes for redirect.dts.extension.
tests/integration/redirect/dtsTsgo.test.ts Update snapshots and test naming to reflect extension redirect being enabled by default (tsgo).
tests/integration/redirect/dtsIsolated.test.ts Update snapshots and test naming to reflect extension redirect being enabled by default (isolated).
tests/integration/redirect/dts/rslib.isolated.config.mts Adjust test matrix configs/dist paths to match new default and the explicit extension: false variant.
tests/integration/redirect/dts/rslib.config.mts Adjust test matrix configs/dist paths to match new default and the explicit extension: false variant.
tests/integration/redirect/dts.test.ts Update snapshots and test naming to reflect extension redirect being enabled by default.
tests/integration/redirect/dts-tsgo/rslib.config.mts Adjust tsgo redirect configs/dist paths for the updated default behavior.
tests/integration/dts/isolated/index.test.ts Update assertions to expect .js specifiers in generated declarations.
tests/integration/dts/composite/index.test.ts Update snapshots to expect .js extensions in re-export specifiers.
tests/integration/dts/bundle-false/index.test.ts Update snapshots to expect .js extensions in rewritten declaration specifiers.
tests/integration/dts/bundle-false/snapshots/index.test.ts.snap Update stored snapshots for .js extension redirects.
tests/integration/dts-tsgo/bundle-false/index.test.ts Update snapshots to expect .js extensions in rewritten declaration specifiers (tsgo).
tests/integration/dts-tsgo/bundle-false/snapshots/index.test.ts.snap Update stored snapshots for .js extension redirects (tsgo).
packages/plugin-dts/src/isolated.ts Change default redirect behavior for isolated DTS post-processing to enable extension redirects.
packages/plugin-dts/src/index.ts Change plugin option default redirect.extension to true.
packages/plugin-dts/src/dts.ts Change DTS generation default redirect behavior to enable extension redirects.
packages/plugin-dts/README.md Update README defaults/docs to reflect extension redirects enabled by default.
packages/core/src/types/config.ts Update redirect.dts.extension documented default to true.

Comment thread website/docs/en/config/lib/redirect.mdx Outdated
Comment thread website/docs/zh/config/lib/redirect.mdx Outdated
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Deploying rslib with  Cloudflare Pages  Cloudflare Pages

Latest commit: 72a53c5
Status: ✅  Deploy successful!
Preview URL: https://4509554c.rslib.pages.dev
Branch Preview URL: https://david-feat-dts-extension-def.rslib.pages.dev

View logs

@Timeless0911
Timeless0911 merged commit ba861d1 into main Jul 22, 2026
12 checks passed
@Timeless0911
Timeless0911 deleted the david/feat-dts-extension-default branch July 22, 2026 11:33
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.

[Bug] redirect.dts.extension edge cases with package-dir aliases and ESM/CJS declaration interop

3 participants

Sponsor
SponsoredKunjungi sekarang
Promo