From 5cc63aa9ea0b4ba3a5dbd563e3644add3c857d1c Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Fri, 30 May 2025 08:49:59 -0700 Subject: [PATCH] Re-expose src/ paths via exports (default) (#51699) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51699 Re-expose **all `"./src/*"` paths via `package.json#exports`. Follows D72228547 — as we'd attempted to be proactive with hiding `src/`, but are now reverting — essentially reducing this change as much as possible (read: most defensive/safer effect on OSS). **Motivation** Mitigates a warning emitted by Metro that may surface in new bare React Native template projects. {F1978757796} This is due to a 1P reference to `'react-native/src/private/featureflags/ReactNativeFeatureFlags` in `react-native/virtualized-lists`. This is enough motivation to undo part of our change with introducing `"exports"` on `react-native` in 0.80. **Especially**, to avoid confusion with other warnings we've intentionally introduced in 0.80 around subpath imports. - The key difference is the above screenshot is from Metro and covers **any** import from any `node_modules` file — as opposed to just the immediate project. Changelog: [General][Changed] - Re-expose `src/*` subpaths when not using the Strict TypeScript API The net breaking change for 0.80, once picked, is simply the presence of `"exports"` (only very edge case effects on expanding per-platform extensions, which we've mitigated). **All exported paths equivalent**. Reviewed By: robhogan Differential Revision: D75682566 fbshipit-source-id: f90c7298279c6be3a4eab70f2dfdc618ffcf1124 --- packages/react-native/package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 5d6236fd387..5451578be13 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -50,6 +50,11 @@ "default": "./Libraries/*.d.ts" }, "./scripts/*": "./scripts/*", + "./src/*": { + "react-native-strict-api": null, + "react-native-strict-api-UNSAFE-ALLOW-SUBPATHS": "./types_generated/src/*.d.ts", + "default": "./src/*.js" + }, "./types/*.d.ts": { "react-native-strict-api": null, "default": "./types/*.d.ts" @@ -61,7 +66,6 @@ "./ReactCommon/*": null, "./sdks/*": null, "./src/fb_internal/*": "./src/fb_internal/*", - "./src/*": null, "./third-party-podspecs/*": null, "./types/*": null, "./types_generated/*": null,