Skip to content
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

[Feature]: Support for DTS paths replacement #409

Open
chenjiahan opened this issue Nov 12, 2024 · 6 comments
Open

[Feature]: Support for DTS paths replacement #409

chenjiahan opened this issue Nov 12, 2024 · 6 comments
Assignees

Comments

@chenjiahan
Copy link
Member

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

  • tsconfig.json:
{
  "compilerOptions": {
    "paths": {
      "rslog": ["./compiled/rslog"]
    }
  },
  "include": ["src"]
}
  • src/index.ts:
import logger from 'rslog';
  • dist/index.d.ts:
import logger from '../compiled/rslog';

What does the proposed API look like?

This should work out of the box.

@Timeless0911
Copy link
Contributor

Sub task of #140

@noshower
Copy link

现在 0.1.5 版本解决了值导入的别名问题,还差类型导入的别名问题没实现,加油

@tutods
Copy link

tutods commented Jan 9, 2025

Any update on this?

@Timeless0911
Copy link
Contributor

Any update on this?

Not yet, you can use tsc-alias to replace alias paths with relative paths after Rslib compilation.

@tutods
Copy link

tutods commented Jan 9, 2025

Any update on this?

Not yet, you can use tsc-alias to replace alias paths with relative paths after Rslib compilation.

But when I try to use the tsc-alias we move all the .d.ts to dist/src while the other files are on dist root.

@Timeless0911
Copy link
Contributor

Timeless0911 commented Jan 9, 2025

But when I try to use the tsc-alias we move all the .d.ts to dist/src while the other files are on dist root.

This is usually due to tsconfig.json wrongly configured, to remove src folder level, we can configure like below:

{
  "compilerOptions": {
    "baseUrl": ".",
    "rootDir": "src",
  },
  "include": ["src"]
}

Open another issue and provide reproduction demo if you have further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants