GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: define "react-native" community condition by huntie · Pull Request #45367 · nodejs/node

Conversation

@huntie

@huntie huntie commented Nov 7, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I'm a React Native maintainer working on Metro, our first-party JavaScript bundler. Here I'm proposing the inclusion of a "react-native" condition under the "Community Conditions Definitions" section of Node's docs.

This is linked to our framework proposal for package exports support: react-native-community/discussions-and-proposals#534.

Why this condition is needed

React Native is a popular platform within the JS ecosystem, where code can be executed in non-browser environments, such as our Hermes JavaScript engine. When package maintainers want to target React Native, we have historically provided a top-level "react-native" root field within package.json — which was an extension of the "browser" field spec (now itself a community condition).

e.g. Used by pusher-js:

image

As with "browser", we are aiming to translate "react-native" to the conditional exports concept.

What the "react-native" condition will represent

These are unchanged from current use of the "react-native" root field.

  • Modules are being required by a React Native app.
  • JavaScript code will be executed under the Hermes or JavaScriptCore runtimes, or a web browser.
  • Modules are most likely being loaded under Metro and babel-preset-react-native.

What will change when this is used as a condition via "exports":

  • Because "exports" allows packages to define the order of conditional exports, package maintainers will have more fine-grained control over what is selected for their package (e.g. matching before, or after, "browser").

Prior usage

Use of "react-native" root field

This is a popular feature and is used by both React Native-specific libraries and larger multiplatform libraries (such as the above pusher-js example). Searching across GitHub, use of the top-level "react-native" field for specifying alternate source files is present in ~20k repositories.

image

Use of "react-native" package exports condition

Webpack already lists "react-native" under its docs for Package exports, which is enabled when configured by the user or in templates under React Native projects.

image

From this we can infer there is independent desire for such a condition, and perhaps limited use today. The definition it provides is "TBD", leaving us to provide the concrete and canonical definition with this PR.

How we teach this

Once "exports" support is ready in Metro:

  • We will update the primary template for new React Native libraries: create-react-native-library.
  • We aim to publish a Metro/React Native website blog post with an upgrade guide for package maintainers.

With the merging of this PR:

  • Package maintainers can optionally get their packages ready for conditional exports in React Native using the documented definition, which we are set on.
    • This will work in Webpack today, but not Metro (until support is shipped).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thymikee, todorone, robhogan, slorber, cortinico, and 4lun reacted with thumbs up emoji
All reactions
  • 👍 6 reactions
@nodejs-github-bot

nodejs-github-bot commented Nov 7, 2022

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/modules
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to Node.js documentation. label Nov 7, 2022
@huntie
huntie marked this pull request as ready for review November 7, 2022 18:05
@huntie
doc: define "react-native" community condition
9d128a3
ljharb
ljharb approved these changes Nov 7, 2022
View reviewed changes
@GeoffreyBooth

GeoffreyBooth commented Nov 8, 2022

Copy link
Copy Markdown
Member

There’s a spec in progress for this: nodejs/tooling#166. I assume we should defer to that spec? cc @nodejs/tsc @guybedford

ljharb reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ljharb

ljharb commented Nov 8, 2022

Copy link
Copy Markdown
Member

+1, but this submission aligns with it so far afaict.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes Nov 8, 2022
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

generically +1, with the WinterCG caveat

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@huntie

huntie commented Nov 8, 2022

Copy link
Copy Markdown
Contributor Author

There’s a spec in progress for this: nodejs/tooling#166. I assume we should defer to that spec? cc @nodejs/tsc @guybedford

@GeoffreyBooth Thanks for raising, we also gave input on the WinterCG spec. Worth noting that "react-native" is subtly different in that context:

  • WinterCG runtime key
    Describes JS runtime environments, therefore represents React Native JS runtimes on native platforms only (Hermes and JavaScriptCore) — and not in browsers via React Native for Web.
  • "exports" condition (this submission)
    Represents React Native projects and matches all runtime platforms (native and web). This is motivated by 1) giving package maintainers control over inclusively matching "react-native" before/after "browser", and 2) consistency with our previous package.json field concept.
GeoffreyBooth, ljharb, hybrist, and motiz88 reacted with thumbs up emoji
All reactions
  • 👍 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mhdawson
mhdawson approved these changes Nov 8, 2022
View reviewed changes

@mhdawson mhdawson left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
legendecas
legendecas approved these changes Nov 9, 2022
View reviewed changes
hybrist
hybrist approved these changes Nov 9, 2022
View reviewed changes
targos
targos approved these changes Nov 9, 2022
View reviewed changes
@huntie huntie mentioned this pull request Nov 11, 2022
RFC: Metro package exports support react-native-community/discussions-and-proposals#534
Merged
@Trott
Trott force-pushed the main branch from 2d76238 to ca3ed36 Compare November 12, 2022 01:49
jasnell
jasnell approved these changes Nov 16, 2022
View reviewed changes
@huntie

huntie commented Nov 28, 2022

Copy link
Copy Markdown
Contributor Author

Hi all, is this good to merge? :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RaisinTen RaisinTen added author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. labels Nov 28, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 28, 2022
@nodejs-github-bot
nodejs-github-bot merged commit d09f0c4 into nodejs:main Nov 28, 2022
@nodejs-github-bot

nodejs-github-bot commented Nov 28, 2022

Copy link
Copy Markdown
Collaborator

Landed in d09f0c4

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@huntie
huntie deleted the react-native-community-condition branch November 28, 2022 15:50
@kelset kelset mentioned this pull request Dec 1, 2022
Use align-deps to help migrate apps to the New Architecture microsoft/rnx-kit#1863
Closed
targos pushed a commit that referenced this pull request Dec 12, 2022
@huntie @targos
doc: define "react-native" community condition
23ff505
PR-URL: #45367
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos targos mentioned this pull request Dec 12, 2022
v19.3.0 release proposal #45831
Merged
@danielleadams danielleadams mentioned this pull request Dec 30, 2022
v18.13.0 release proposal #46025
Merged
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
@huntie @danielleadams
doc: define "react-native" community condition
02b61d6
PR-URL: #45367
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
@huntie @danielleadams
doc: define "react-native" community condition
6881188
PR-URL: #45367
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
danielleadams pushed a commit that referenced this pull request Jan 5, 2023
@huntie @danielleadams
doc: define "react-native" community condition
17d4498
PR-URL: #45367
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@kelset kelset mentioned this pull request Jan 26, 2023
RFC: introduce reactNativeManifest to package.json react-native-community/discussions-and-proposals#588
Closed
@TomCorvus TomCorvus mentioned this pull request Jun 30, 2025
add react-native field in package.json douglasjunior/react-native-pdf-renderer#47
Merged
@carvalhoviniciusluiz carvalhoviniciusluiz mentioned this pull request May 17, 2026
[React Native] Unable to resolve module cpf-cnpj-validator/zod carvalhoviniciusluiz/cpf-cnpj-validator#50
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ljharb ljharb ljharb approved these changes
@mcollina mcollina mcollina approved these changes
@jasnell jasnell jasnell approved these changes
@hybrist hybrist hybrist approved these changes
@legendecas legendecas legendecas approved these changes
+2 more reviewers
@targos targos targos approved these changes
@mhdawson mhdawson mhdawson approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. doc Issues and PRs related to Node.js documentation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

11 participants

@huntie @nodejs-github-bot @GeoffreyBooth @ljharb @mcollina @jasnell @hybrist @targos @legendecas @mhdawson @RaisinTen
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.