Skip to content

Skip plugin for non-Flow JS code - #1556

Closed
huntie wants to merge 1 commit into
meta:mainfrom
huntie:export-D65272155
Closed

huntie wants to merge 1 commit into
meta:mainfrom
huntie:export-D65272155

Conversation

@huntie

@huntie huntie commented Oct 31, 2024 •

Copy link
Copy Markdown
Contributor

Summary:
This is a mitigation for #1549.

Updates babel-plugin-syntax-hermes-parser to include a new parseLangTypes option, which we will configure in React Native's Babel preset to abort when the file contents do not include @flow.

Context: React Native

Originally changed in react/react-native#46696, as our internal Flow support had diverged from babel/plugin-syntax-flow (react/react-native#46601).

We effectively have three flavours of JavaScript in support:

  • Flow@latest for the react-native package, shipped as source — uses hermes-parser.
  • TypeScript for product code (community template, Expo) — uses babel/plugin-syntax-typescript.
  • Plain JavaScript/JSX in product code, which may be extended with additional user Babel plugins and needs lenient parsing — uses base babel/parser (this change).

I'd love to simplify this 😅.

Differential Revision: D65272155

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Oct 31, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D65272155

huntie added a commit to huntie/hermes that referenced this pull request Oct 31, 2024
Summary:

This is a mitigation for meta#1549.

Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`.

**Context: React Native**

Originally changed in react/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (react/react-native#46601).

We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**).

I'd love to simplify this 😅.

Reviewed By: cipolleschi

Differential Revision: D65272155
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D65272155

huntie added a commit to huntie/hermes that referenced this pull request Oct 31, 2024
Summary:

This is a mitigation for meta#1549.

Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`.

**Context: React Native**

Originally changed in react/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (react/react-native#46601).

We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**).

I'd love to simplify this 😅.

Reviewed By: robhogan, cipolleschi

Differential Revision: D65272155
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D65272155

huntie added a commit to huntie/hermes that referenced this pull request Nov 1, 2024
Summary:

This is a mitigation for meta#1549.

Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`.

**Context: React Native**

Originally changed in react/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (react/react-native#46601).

We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**).

I'd love to simplify this 😅.

Differential Revision: D65272155
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D65272155

huntie added a commit to huntie/hermes that referenced this pull request Nov 1, 2024
Summary:

This is a mitigation for meta#1549.

Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`.

**Context: React Native**

Originally changed in react/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (react/react-native#46601).

We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**).

I'd love to simplify this 😅.

Differential Revision: D65272155
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D65272155

huntie added a commit to huntie/hermes that referenced this pull request Nov 1, 2024
Summary:

This is a mitigation for meta#1549.

Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`.

**Context: React Native**

Originally changed in react/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (react/react-native#46601).

We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**).

I'd love to simplify this 😅.

Differential Revision: D65272155
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D65272155

huntie added a commit to huntie/hermes that referenced this pull request Nov 4, 2024
Summary:

This is a mitigation for meta#1549.

Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`.

**Context: React Native**

Originally changed in react/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (react/react-native#46601).

We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**).

I'd love to simplify this 😅.

Reviewed By: vzaidman

Differential Revision: D65272155
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D65272155

@jbroma

jbroma commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

Doesn’t hermes-parser handle this internally? I'm curious—how does this differ from the flow: 'detect' option in hermes-parser?

Reference: https://github.com/facebook/hermes/blob/8e238330effbbea6d2934f429839a74d1131a1a4/tools/hermes-parser/js/hermes-parser/src/index.js#L26

@huntie

huntie commented Nov 4, 2024 •

Copy link
Copy Markdown
Contributor Author

@jbroma There's hermes-parser (directly) and babel-plugin-syntax-hermes-parser (this integration). Looks like this plugin is the point correctly to eject out of hermes-parser handling (to implement the flow arg) under Babel.

The test plan for this change requires transformer.hermesParser to be set false in Metro.

@jbroma

jbroma commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

@jbroma There's hermes-parser (directly) and babel-plugin-syntax-hermes-parser (this integration). Looks like this plugin is the point correctly to eject out of hermes-parser handling (to implement the flow arg) under Babel.

The test plan for this change requires transformer.hermesParser to be set false in Metro.

thanks for clearing that up! makes sense 👍

Summary:

This is a mitigation for meta#1549.

Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`.

**Context: React Native**

Originally changed in react/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (react/react-native#46601).

We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**).

I'd love to simplify this 😅.

Differential Revision: D65272155
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D65272155

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in f2970e7.

facebook-github-bot pushed a commit that referenced this pull request Nov 8, 2024
Summary:
Release version to 0.25.1

This release includes #1556, which will be configured in React Native to opt-out from `hermes-parser` under Babel for untyped JS — fixing compat with 3P plugins by users.

(See react/react-native#46601, react/react-native#46696.)

Reviewed By: cortinico

Differential Revision: D65661003

fbshipit-source-id: faa0ea0a507b2b46ef7cf52fdabe3e3ff0a3851e
facebook-github-bot pushed a commit that referenced this pull request Nov 14, 2024
Summary:
Original Author: huntie@meta.com
Original Git: f2970e7
Original Reviewed By: pieterv
Original Revision: D65272155

Pull Request resolved: #1556

This is a mitigation for #1549.

Updates `babel-plugin-syntax-hermes-parser` to include a new `parseLangTypes` option, which we will configure in React Native's Babel preset to abort when the file contents do not include `flow`.

**Context: React Native**

Originally changed in react/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (react/react-native#46601).

We effectively have three flavours of JavaScript in support:
- Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`.
- TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`.
- Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**).

I'd love to simplify this 😅.

Reviewed By: mattbfb

Differential Revision: D65787624

fbshipit-source-id: b06f1499b2d02462777ac72f03d8bb5c713b0a19
facebook-github-bot pushed a commit that referenced this pull request Nov 14, 2024
Summary:
Original Author: huntie@meta.com
Original Git: 15e9b5c
Original Reviewed By: cortinico
Original Revision: D65661003

Release version to 0.25.1

This release includes #1556, which will be configured in React Native to opt-out from `hermes-parser` under Babel for untyped JS — fixing compat with 3P plugins by users.

(See react/react-native#46601, react/react-native#46696.)

Reviewed By: mattbfb

Differential Revision: D65787623

fbshipit-source-id: f6b56d44cdb992ca01de75df384b4599bef8432b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants