fix: add /index.js to dayjs ESM import remap#753
Conversation
Host apps with "type": "module" using strict ESM resolvers (Node nodenext) fail to resolve bare dayjs/esm/plugin/<name> since dayjs lacks exports map for esm subpaths and plugin paths are directories. Append /index.js in rollup output paths to produce fully qualified imports that work across Bun, Node strict ESM, Vite SSR, and bundlers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change updates the Rollup configuration to explicitly specify module entry paths for the Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
pathsrewritesdayjs/dayjs/plugin/*→dayjs/esm*in ESM builds, but emitted bare paths likedayjs/esm/plugin/customParseFormatwithout extension.dayjshas noexportsmap for esm subpaths, and plugin paths are directories (customParseFormat/index.js). Strict ESM resolvers (Nodenodenext, host apps with"type": "module") fail to resolve directory imports without an explicit path./index.jsin the remap so output references the actual file. Works in Bun, Node strict ESM, Vite SSR, and bundlers alike.Test plan
pnpm build— ESM dist imports resolve todayjs/esm/index.jsanddayjs/esm/plugin/<name>/index.jsrequire('dayjs'),require('dayjs/plugin/<name>'))pnpm test— 1663/1663 pass"type": "module"(Bun/Next) imports DatePicker/RangePicker/DataTable date filters without resolution errors🤖 Generated with Claude Code