Skip to content

fix: bundle dts files for ESM packages#2347

Merged
chenjiahan merged 2 commits intomainfrom
bundle_dts_0515
May 15, 2024
Merged

fix: bundle dts files for ESM packages#2347
chenjiahan merged 2 commits intomainfrom
bundle_dts_0515

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

@chenjiahan chenjiahan commented May 15, 2024

Summary

If the dts files are not bundled, users may use "moduleResolution": "Node16" in their tsconfig.json, and TypeScript only allow import paths in *.d.ts to include the .js extension, otherwise the dts module resolution will be broken.

Current:

// foo.d.ts
import { bar } from './bar'; 

TS expected (with: "moduleResolution": "Node16")

// foo.d.ts
import { bar } from './bar.js'; 

Solution

  • Bundle dts files for ESM packages can solve this issue.
  • Complete the /compiled/package/index.js paths, because the type of compiled packages are not bundled into index.d.ts.

Related Links

Checklist

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

@netlify
Copy link
Copy Markdown

netlify bot commented May 15, 2024

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 6e37b39
🔍 Latest deploy log https://app.netlify.com/sites/rsbuild/deploys/66444696f925f60008d8a4a0
😎 Deploy Preview https://deploy-preview-2347--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 71 (🔴 down 8 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

@chenjiahan chenjiahan merged commit 5276818 into main May 15, 2024
@chenjiahan chenjiahan deleted the bundle_dts_0515 branch May 15, 2024 05:31
JSerFeng pushed a commit that referenced this pull request May 15, 2024
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.

1 participant