Skip to content

globalClassNamePolyfill: AssetRegistry missing from react-native re-export whitelist #506

Open

Description

@EdoTM

Bug

With NativeWind v5 / globalClassNamePolyfill: true, Metro remaps import … from 'react-native' to react-native-css/components. That entry (src/components/index.cts) is a hand-maintained whitelist of RN exports.

AssetRegistry is not on the list. Callers such as expo-asset then do:

import { AssetRegistry } from 'react-native';
AssetRegistry.getAssetByID(id); // Cannot read property 'getAssetByID' of undefined

This breaks Material Symbol loading for Expo Router NativeTabs md icons (and any other expo-asset / font path that uses AssetRegistry).

Fix

Add the same getter pattern used for AppRegistry / AppState:

get AssetRegistry() {
  return require("react-native").AssetRegistry;
},

after AppState in src/components/index.cts (and rebuild dist).

require("react-native") from inside this package stays on the real RN module because the Metro resolver treats react-native-css as internal and does not remapped it.

Environment

  • nativewind@5.0.0-rc.0
  • react-native-css@3.1.0-rc.0
  • react-native@0.88 / Expo SDK 58
  • expo-asset importing AssetRegistry from react-native

Happy to open a PR if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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