web-infra-dev / rslib

Create JavaScript libraries in a simple and intuitive way.
https://lib.rsbuild.dev/
MIT License
420 stars 22 forks source link

[Feature]: Support for DTS paths replacement #409

Open chenjiahan opened 5 days ago

chenjiahan commented 5 days ago

What problem does this feature solve?

The compilerOptions#paths in tsconfig.json should work for DTS output.

Modern.js Module supports this, see https://github.com/web-infra-dev/modern.js/blob/main/packages/solutions/module-tools/src/utils/dts.ts#L116

{
  "compilerOptions": {
    "paths": {
      "rslog": ["./compiled/rslog"]
    }
  },
  "include": ["src"]
}
import logger from 'rslog';
import logger from '../compiled/rslog';

What does the proposed API look like?

This should work out of the box.

Timeless0911 commented 5 days ago

Sub task of #140