Skip to content

Conversation

@mozisan
Copy link

@mozisan mozisan commented Oct 28, 2025

📝 Description

Migrate @heroui/react to ESM by adding explicit .js extensions to all relative imports and updating the TS config.
This fixes type resolution for ESM consumers of @heroui/react@alpha.

⛳️ Current behavior (updates)

Currently, while packages/react/package.json specifies "type": "module", the source code and build process are not fully ESM-compliant:

  • Source code's import/export statements omit file extensions in from clauses (e.g., from "./button")
  • TypeScript configuration uses "moduleResolution": "Bundler", which doesn't enforce extension requirements
  • As a result, generated .d.ts files also have import/export statements without file extensions in from clauses

This causes type resolution failures when importing @heroui/react from ESM projects.

🚀 New behavior

  • All relative imports now include explicit .js extensions (e.g., from "./button.js")
  • Directory imports explicitly reference index.js files (e.g., from "../../utils/index.js")
  • TypeScript config updated to use "module": "NodeNext" and "moduleResolution": "NodeNext"
  • Generated .d.ts files include .js extensions for proper type resolution

Verification

  • pnpm build succeeds
  • pnpm lint passes
  • pnpm typecheck passes
  • Storybook starts successfully

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

Storybook Files Not Updated

The *.stories.tsx files still use extensionless imports.

I intentionally excluded them from this PR because:

  1. Storybook starts successfully with these changes
  2. Including Storybook files would significantly expand the PR scope

If the team prefers, I'm happy to include Storybook file updates in this PR or a follow-up.

- Update TypeScript config to use NodeNext module resolution for proper
  ESM type generation
- Add .js extensions to all relative imports in source files for ESM
  compatibility
- Ensure generated .d.ts files include .js extensions for proper type
  resolution in ESM projects
- Fix directory imports to explicitly reference index.js files

This change ensures that @heroui/react can be properly imported in ESM
projects with correct type resolution.
@mozisan mozisan requested a review from jrgarciadev as a code owner October 28, 2025 21:58
@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

⚠️ No Changeset found

Latest commit: 470a29b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 28, 2025

@mozisan is attempting to deploy a commit to the HeroUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

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.

1 participant