Skip to content

Deprecate @react-native/assets-registry#57370

Open
huntie wants to merge 3 commits into
react:mainfrom
huntie:export-D110053924
Open

Deprecate @react-native/assets-registry#57370
huntie wants to merge 3 commits into
react:mainfrom
huntie:export-D110053924

Conversation

@huntie

@huntie huntie commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary:
Context

This stack intends to relocate AssetRegistry API from @react-native/assets-registry into react-native — addressing runtime safety and public deep imports issues (1.0 and JS Stable API blockers).

This diff

Deprecate the @react-native/assets-registry package, replaced by changes in the last two diffs:

  • @react-native/assets-registry/registry → use AssetRegistry from react-native (or the react-native/asset-registry build entry point).
  • @react-native/assets-registry/path-support → use react-native/asset-utils.

Deprecation plan

The package will be deprecated for two release cycles (0.87 + 0.88) and deleted in 0.89.

Changelog:
[General][Deprecated] - Deprecate @react-native/assets-registry. Use AssetRegistry from react-native and @react-native/asset-utils instead.

Differential Revision: D110053924

huntie added 3 commits June 29, 2026 08:19
Summary:
**Context**

This stack intends to relocate `AssetRegistry` API from `react-native/assets-registry` into `react-native` — addressing runtime safety and public deep imports issues (1.0 and JS Stable API blockers).

**This diff**

Create a new `react-native/asset-utils` package, intended for internal/framework use (read: **will not be an end user concern**). This re-houses `react-native/assets-registry/path-support.js`.

Stacked with the next two diffs, this contributes to the 0.87 objective to delete `react-native/assets-registry` towards install-layout-safe behaviour and JS deep import removal.

- (Temporarily, this leaves two copies of `path-support.js` until I enact the package removal down the stack.)

This change also enables us to de-duplicate `assetPathUtils.js` inside `community-cli-plugin` and use one source of truth.

- Additionally, we have fbsource consumers of this util that cannot have a circular Buck dep on `react-native`, so the main package was not a suitable relocation point (secondarily to not adding an awkward new public API here).

**Changes**
- Add `react-native/asset-utils` (`packages/asset-utils/`): `src/AssetPathUtils.js` containing Android path helpers and tests.
- De-duplicate usages in `community-cli-plugin`: delete `src/commands/bundle/assetPathUtils.js`.

Changelog:
[General][Added] - Introduce `react-native/asset-utils` package (relocates Android path utils for libraries/frameworks)

Differential Revision: D110045272
… API

Summary:
NOTE: Squash of react#57233 (D108750302) and react#57232 (D108750303)

**This diff** solves two distinct problems.

**Problem 1 — `react-native/assets-registry` is a stateful-singleton footgun.**

`registry.js` holds asset state in a module-scoped variable, so exactly one instance must exist per JS runtime or registration and lookup diverge. Nothing guarantees this: the `node_modules` install layout decides how many copies exist, and `react-native`'s exact-version pin means third-party ranges never dedupe against it. Consumers silently break — `expo-asset`/`expo-image` can land on a second copy where assets register in one and resolve as `undefined` from the other (Expo neutralizes this with a virtual-module shim in `expo/cli`; bare React Native + Metro has no such protection). It also blocks 1.0: the ecosystem can't move from exact-version lockstep to semver ranges until stateful packages like this are safe to duplicate.

**Problem 2 — Metro configs depend on a deep `/Libraries/...` import.**

Metro configs reference `transformer.assetRegistryPath` via a deep `react-native/Libraries/Image/AssetRegistry` import. We want to replace it with a public entry point, but we can't reuse the new index `AssetRegistry` API directly — doing so breaks Metro's API contract (it generates an inline require). We need a dedicated wrapper module that can be read without destructuring.

**This diff**

1. Moves the `AssetRegistry` implementation into the main `react-native` package, adding the `AssetRegistry` API plus the `PackagerAsset` and `AssetDestPathResolver` root type exports. `react-native/assets-registry` now sources from this relocated implementation, fixing the duplicate-install bug wherever apps/frameworks enforce a single copy of `react-native`. Imports from either package in RN 0.87+ become durable to duplicate installs, so Expo can drop their virtual-module shim.
2. Adds a new `react-native/asset-registry` secondary entry point, intended and documented for the Metro config use case, and migrates our own `react-native/metro-config` onto it (replacing the `transformer.assetRegistryPath` deep import). Deprecates `react-native/assets-registry/registry` and removes `react-native/Libraries/Image/AssetRegistry`, standardizing on `AssetRegistry` (singular) as canonical.

Changelog:
- [General][Fixed] - **assets-registry**: `react-native/assets-registry` now shares state across duplicate installs, sourcing from a relocated implementation in the `react-native` package
- [General][Added] - Add `AssetRegistry` API (replaces `react-native/assets-registry/registry`)
- [General][Breaking] - `react-native/Libraries/Image/AssetRegistry` is removed. Please use the `AssetRegistry` API (apps/library code) and/or the `react-native/asset-registry` entrypoint (Metro/build configs).
- [General][Deprecated] - **assets-registry**: `react-native/assets-registry/registry` is deprecated. Please use the `AssetRegistry` API (apps/library code) and/or the `react-native/asset-registry` entrypoint (Metro/build configs).

Differential Revision: D109019622
Summary:
**Context**

This stack intends to relocate `AssetRegistry` API from `react-native/assets-registry` into `react-native` — addressing runtime safety and public deep imports issues (1.0 and JS Stable API blockers).

**This diff**

Deprecate the `react-native/assets-registry` package, replaced by changes in the last two diffs:

- `react-native/assets-registry/registry` → use `AssetRegistry` from `react-native` (or the `react-native/asset-registry` build entry point).
- `react-native/assets-registry/path-support` → use `react-native/asset-utils`.

**Deprecation plan**

The package will be deprecated for **two release cycles** (0.87 + 0.88) and deleted in 0.89.

Changelog:
[General][Deprecated] - Deprecate `react-native/assets-registry`. Use `AssetRegistry` from `react-native` and `react-native/asset-utils` instead.

Differential Revision: D110053924
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 29, 2026
@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_NON_BREAKING

@meta-codesync

meta-codesync Bot commented Jun 29, 2026

Copy link
Copy Markdown

@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D110053924.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant