feat(dts)!: enable declaration extension redirects by default - #1784
Conversation
BREAKING CHANGE: Declaration import paths now use runtime JavaScript extensions by default. Set `redirect.dts.extension` to `false` to preserve existing specifiers.
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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
falsetotrueacross core/plugin defaults and type docs. - Update integration tests and snapshots to expect redirected
.jsspecifiers by default, and adjust the explicit “extension: false” cases accordingly. - Expand the redirect docs (EN/ZH) with caveats for
paths/dts.aliaspath 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. |
Deploying rslib with
|
| 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 |
Summary
redirect.dts.extensionby default so declaration imports use runtime JavaScript extensions without extra configuration.redirect.dts.extensiontofalseto preserve the previous behavior.Related Links
Closes #1733
Checklist