Skip to content

fix: expose missing NATIVEWIND_OS in NativeWind plugin #1173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 17, 2025

Conversation

raghav-reglobe
Copy link
Contributor

@raghav-reglobe raghav-reglobe commented Jun 13, 2025

Problem statement

nativewind/preset chooses web, when process.env.NATIVEWIND_OS !== "native" or is undefined.
The Re-Pack plug-in never sets that variable, so Tailwind’s web defaults win and the angle variables
(--tw-rotate, --tw-skew-x/y) are emitted as bare 0 → Android crashes.

Metro does set the var (via withNativeWind()), so the two bundlers behave differently.

Proposed fix

Force the platform passed to nativewind/preset.

  • "native" (default) | "web" | undefined (use env as-is)

Why this solves the root bug (no work-arounds)

  • When Tailwind runs, the native preset adds
    --tw-rotate: 0deg; --tw-skew-x:0deg; --tw-skew-y:0deg to the reset layer,
    so the generated CSS already has the correct units.
  • The loader no longer needs to post-process cssToReactNativeRuntime output,
    and palette colours work unchanged.

Copy link

changeset-bot bot commented Jun 13, 2025

🦋 Changeset detected

Latest commit: 2a73b14

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Patch
@callstack/repack-plugin-nativewind Patch
@callstack/repack-plugin-expo-modules Patch
@callstack/repack-plugin-reanimated Patch
@callstack/repack-dev-server Patch
@callstack/repack-init Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link

vercel bot commented Jun 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
repack-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 8:31am

Copy link
Member

@jbroma jbroma left a comment

Choose a reason for hiding this comment

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

hi @raghav-reglobe 👋 thanks for the PR!

left some comments 👇

**Commit message:**

Set `process.env.NATIVEWIND_OS` based on `compiler.options.name` if it is "android" or "ios" in NativeWind plugin

- Removes `presetPlatform` option and related logic.
- Automatically sets `process.env.NATIVEWIND_OS` to "android" or "ios" if `compiler.options.name` matches.
- Ensures consistent platform detection for NativeWind builds.
Removed unused commit.
Copy link
Member

@jbroma jbroma left a comment

Choose a reason for hiding this comment

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

code looks good 👍

please add changeset entry by running pnpm changeset in root of the monorepo

@jbroma
Copy link
Member

jbroma commented Jun 16, 2025

@raghav-reglobe please also run pnpm lint in the root and commit the changes 👍

added: changeset
@jbroma jbroma changed the title Added missing Nativewind OS to add platform defaults. fix: expose missing NATIVEWIND_OS in NativeWind plugin. Jun 17, 2025
@jbroma jbroma changed the title fix: expose missing NATIVEWIND_OS in NativeWind plugin. fix: expose missing NATIVEWIND_OS in NativeWind plugin Jun 17, 2025
@jbroma jbroma merged commit 175a60a into callstack:main Jun 17, 2025
5 checks passed
@jbroma
Copy link
Member

jbroma commented Jun 17, 2025

@raghav-reglobe thank you for your contribution 🎉

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