Skip to content

getOptimizeDeps unconditionally requires nativewind/jsx-dev-runtime, breaks with NativeWind v5 #729

Description

@natew

Symptom

Any vxrn project that has nativewind v5 installed in node_modules (even if vxrn isn't actively using it - e.g. a transitive dep, or a sibling workspace's dep) fails to boot vite with:

ERROR  "./jsx-dev-runtime" is not exported under the conditions ["vxrn-web", "import"] from package /…/node_modules/nativewind

The dev server never comes up.

Root cause

packages/vxrn/src/config/getOptimizeDeps.ts (lines 7-14 on main @ 993f36a) unconditionally lists nativewind subpaths in the needsInterop array:

const needsInterop = [
  'nativewind/jsx-dev-runtime',
  'nativewind/jsx-runtime',
  'nativewind',

  'react-native-css-interop/jsx-runtime',
  'react-native-css-interop/jsx-dev-runtime',
  'react-native-css-interop',
  ...
]

NativeWind v5 (5.0.0-preview.4 and later) dropped the jsx-dev-runtime / jsx-runtime subpath exports. Its package.json exports field now only declares:

['.', './babel', './metro', './types', './theme']

Because vxrn passes these entries to vite's optimizeDeps, vite tries to resolve nativewind/jsx-dev-runtime against the installed package and hits the export-conditions check, which throws and kills startup.

Reproduction

  1. Any vxrn / one project
  2. Add nativewind@5 anywhere reachable in node_modules (direct dep, transitive, or even a sibling workspace package - vite still resolves it from the project root)
  3. vxrn dev / one dev -> error above, server never starts

Workaround

Remove nativewind from node_modules (e.g. mv node_modules/nativewind /tmp/). Confirmed working - dev server boots immediately.

Suggested fix

Either:

(a) Wrap the nativewind entries in a resolve guard - only include subpaths that actually resolve, e.g. check the installed nativewind/package.json exports map before adding jsx-dev-runtime / jsx-runtime. Same pattern could apply to react-native-css-interop.

(b) Detect the installed nativewind major from node_modules/nativewind/package.json at config-init time. For v5+, only include 'nativewind' (or drop entirely if v5 no longer needs interop pre-bundling at all - the CSS-interop story changed).

(a) is more robust against future similar drops in either package.

Context

Hit this in the tamagui monorepo - cc @natew. Happy to PR if a direction is preferred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions