-
Notifications
You must be signed in to change notification settings - Fork 32
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
[Bug]: generated .d.ts not handle imports' extensions correctly #678
Comments
This is a very complex topic. Rslib generate DTS files as same as But for DTS files, Typescript do not do such rewrite now. Adding |
Thanks for your reply, I previously used |
I remember that this plugin can only deal with Javascript output files. For DTS files, Currently, in Rslib, you can write an Rsbuild plugin to modify DTS files after emitting: import type { RsbuildPlugin } from '@rsbuild/core';
import { defineConfig } from '@rslib/core';
const pluginFixDts: RsbuildPlugin = {
name: 'fix-dts',
setup(api) {
api.onAfterBuild({
handler: () => {
// ...
},
// Set the order to 'post' to ensure that DTS files emitted after the build is complete.
order: 'post',
});
},
};
export default defineConfig({
plugins: [pluginFixDts]
lib: [
// ...
],
}); BTW, for dual packages, I prefer to provide one piece of DTS exports, you can refer |
I also think the double DTS file is redundant. I'll give it a try. |
Version
System: OS: Windows 11 10.0.26100 CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700 Memory: 2.34 GB / 15.77 GB Browsers: Edge: Chromium (131.0.2903.63) Internet Explorer: 11.0.26100.1882 npmPackages: @rslib/core: ^0.3.1 => 0.3.1
Details
dist/es/index.d.ts
expected:
actual:
dist/lib/index.d.cts
expected:
actual:
Reproduce link
https://github.com/Jungzl/rslib-project-issue-demo/tree/issue/dts
Reproduce Steps
after manually add extensions from above:
The text was updated successfully, but these errors were encountered: