Skip to content

fix: add /index.js to dayjs ESM import remap#753

Merged
rsbh merged 1 commit intomainfrom
fix_dayjs_esm_import_1
Apr 23, 2026
Merged

fix: add /index.js to dayjs ESM import remap#753
rsbh merged 1 commit intomainfrom
fix_dayjs_esm_import_1

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented Apr 23, 2026

Summary

  • Rollup output paths rewrites dayjs / dayjs/plugin/*dayjs/esm* in ESM builds, but emitted bare paths like dayjs/esm/plugin/customParseFormat without extension.
  • dayjs has no exports map for esm subpaths, and plugin paths are directories (customParseFormat/index.js). Strict ESM resolvers (Node nodenext, host apps with "type": "module") fail to resolve directory imports without an explicit path.
  • Append /index.js in 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 to dayjs/esm/index.js and dayjs/esm/plugin/<name>/index.js
  • CJS dist unchanged (require('dayjs'), require('dayjs/plugin/<name>'))
  • pnpm test — 1663/1663 pass
  • Verify consumer host app with "type": "module" (Bun/Next) imports DatePicker/RangePicker/DataTable date filters without resolution errors

🤖 Generated with Claude Code

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>
@rsbh rsbh requested a review from rohanchkrabrty April 23, 2026 04:26
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
apsara Ready Ready Preview, Comment Apr 23, 2026 4:28am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5280f1bc-36ec-4bcf-8f20-11ec3f5f07ca

📥 Commits

Reviewing files that changed from the base of the PR and between 3997059 and 6139a62.

📒 Files selected for processing (1)
  • packages/raystack/rollup.config.mjs

📝 Walkthrough

Walkthrough

This change updates the Rollup configuration to explicitly specify module entry paths for the dayjs library. The modification directs imports of dayjs to resolve to dayjs/esm/index.js instead of the directory path dayjs/esm. Additionally, plugin imports matching the dayjs/plugin/* pattern are updated to include the explicit index.js segment, resolving to dayjs/esm/plugin/*/index.js. This ensures more precise module resolution during the build process.

Suggested reviewers

  • rohanchkrabrty
  • paanSinghCoder
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding /index.js to dayjs ESM import remapping in the Rollup configuration.
Description check ✅ Passed The description provides clear context about the problem, solution, and test plan, all directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rsbh rsbh merged commit 3cf0c70 into main Apr 23, 2026
5 checks passed
@rsbh rsbh deleted the fix_dayjs_esm_import_1 branch April 23, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants