Skip to content

Conversation

@zoryana94
Copy link
Contributor

No description provided.

@zoryana94 zoryana94 requested a review from a team as a code owner January 2, 2026 16:19
"regenerator": true
}],
[
"babel-plugin-transform-rewrite-imports",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zoryana94 thank you for addressing this fix!

I think the plugin babel-plugin-transform-rewrite-imports is inside env.esm, so it only runs for the ESM build.

The CJS build uses npm run transpile which doesn't set BABEL_ENV=esm, so the plugin doesn't run.

  • dist/esm/hooks/index.js -> "./useHCaptcha.js" ✅
  • dist/hooks/index.js -> "./useHCaptcha.jsx" ❌

We may want to move the plugin to the root plugins array instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also opened this other PR as a simpler alternative.

It uses .js extensions directly in the source files instead of relying on a Babel plugin.
No new dependencies, works for both CJS and ESM.

The only tradeoff is a small moduleNameMapper config in Jest to resolve .js -> .jsx during tests.

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