Skip to content

feat(dts): support dts.alias #1135

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

Merged
merged 4 commits into from
Jul 30, 2025
Merged

feat(dts): support dts.alias #1135

merged 4 commits into from
Jul 30, 2025

Conversation

Timeless0911
Copy link
Contributor

Summary

dts.alias

  • Type: Record<string, string>
  • Default: {}

Configure the path alias for declaration files.

dts.alias will be merged with compilerOptions.paths configured in tsconfig.json and dts.alias has a higher priority.

In most cases, you don't need to use dts.alias, but consider using it when you need to use path alias only in declaration files without wanting to affect JavaScript outputs. For example, map the declaration file of foo to ./compiled/foo.

export default {
  lib: [
    {
      // [!code highlight:5]
      dts: {
        alias: {
          foo: './compiled/foo',
        },
      },
    },
  ],
};

Related Links

Checklist

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

@Copilot Copilot AI review requested due to automatic review settings July 29, 2025 08:59
Copy link

@Copilot Copilot AI left a comment

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 adds support for a new dts.alias configuration option that allows configuring path aliases specifically for TypeScript declaration files. The feature enables users to set path aliases that only affect declaration file generation without impacting JavaScript output.

  • Adds a new dts.alias configuration option of type Record<string, string>
  • Implements merging logic that combines dts.alias with tsconfig.json paths, with dts.alias taking higher priority
  • Updates documentation in both English and Chinese to explain the new feature

Reviewed Changes

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

Show a summary per file
File Description
packages/core/src/types/config.ts Adds the alias property to the Dts type definition
packages/core/src/config.ts Passes the dts.alias option to the DTS plugin configuration
packages/plugin-dts/src/index.ts Adds alias parameter to PluginDtsOptions and initializes default value
packages/plugin-dts/src/dts.ts Implements the alias merging logic with tsconfig paths
packages/plugin-dts/src/utils.ts Adds utility function mergeAliasWithTsConfigPaths for merging aliases
packages/plugin-dts/src/tsc.ts Updates function signatures to pass paths through the processing pipeline
packages/plugin-dts/README.md Documents the new alias option with usage examples
website/docs/en/config/lib/dts.mdx Adds English documentation for the new dts.alias configuration
website/docs/zh/config/lib/dts.mdx Adds Chinese documentation for the new dts.alias configuration
website/docs/en/guide/advanced/dts.mdx Updates the configuration table to include the new option
website/docs/zh/guide/advanced/dts.mdx Updates the configuration table to include the new option
tests/integration/dts/bundle-false/alias/* Adds integration test files for the new alias functionality
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copy link

netlify bot commented Jul 29, 2025

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit 183eee2
🔍 Latest deploy log https://app.netlify.com/projects/rslib/deploys/6888af1c6343c00008f38b1f
😎 Deploy Preview https://deploy-preview-1135--rslib.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Timeless0911 Timeless0911 requested a review from fi3ework July 30, 2025 06:18
@Timeless0911 Timeless0911 merged commit 6b7cade into main Jul 30, 2025
14 checks passed
@Timeless0911 Timeless0911 deleted the feat/dts-alias branch July 30, 2025 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants