Skip to content

fix: inject cjs instead of esm to initialize#501

Merged
Brentlok merged 1 commit intomainfrom
fix/expo-tree-shaking
Apr 21, 2026
Merged

fix: inject cjs instead of esm to initialize#501
Brentlok merged 1 commit intomainfrom
fix/expo-tree-shaking

Conversation

@Brentlok
Copy link
Copy Markdown
Contributor

@Brentlok Brentlok commented Apr 21, 2026

Fixes #500

In debug mode / without tree shaking metro was converting all files to CJS.
It doesn't do this in optimized, tree shaking build so it caused error.
Common JS is correct format on native

Summary by CodeRabbit

  • Chores
    • Updated mobile/TV CSS transformation build process for improved compatibility.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c2d90804-2a3e-4bdf-8b20-3f6c7e3a0314

📥 Commits

Reviewing files that changed from the base of the PR and between dfaa63d and eebe10c.

📒 Files selected for processing (1)
  • packages/uniwind/src/metro/metro-transformer.ts

📝 Walkthrough

Walkthrough

A single-line modification in the metro transformer's non-web CSS transformation path, replacing an ES module import statement with a CommonJS require destructuring pattern for compatibility with tree-shaking-enabled build environments.

Changes

Cohort / File(s) Summary
Metro Transformer Bootstrap
packages/uniwind/src/metro/metro-transformer.ts
Changed injected bootstrap code from ES module import (import { Uniwind } from '${name}';) to CommonJS require (const { Uniwind } = require('${name}');) in the non-web transformation path.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through module land,
ES imports? They don't understand!
CommonJS require saves the day,
Tree-shaking works in every way! 🌳✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: switching from ES module import to CommonJS require for initialization injection in the Metro transformer.
Linked Issues check ✅ Passed The code change directly addresses issue #500 by replacing ESM import with CJS require, which resolves the Hermes bytecode generation error when Expo tree shaking is enabled.
Out of Scope Changes check ✅ Passed The single-line change is narrowly scoped to fixing the specific initialization injection mechanism for non-web environments, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/expo-tree-shaking

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.

@Brentlok Brentlok merged commit e0c91ee into main Apr 21, 2026
2 checks passed
@Brentlok Brentlok deleted the fix/expo-tree-shaking branch April 21, 2026 06:50
@github-actions
Copy link
Copy Markdown
Contributor

🚀 This pull request is included in v1.6.3. See Release v1.6.3 for release notes.

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.

Uniwind causes build failure on Expo 55 when enabling tree shaking

1 participant