Skip to content

Commit

Permalink
Substitute babel-preset-fbjs for metro-transform-plugins (#46689)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46689

Resubmission of D61014834 / #45959 (previously reverted).

> Addresses TODO comment. I noticed this lone reference to babel-preset-fbjs (last published 3y ago) while attempting to upgrade our Babel Flow syntax plugin.

Changelog: [Internal]

Differential Revision: D63532211
  • Loading branch information
huntie authored and facebook-github-bot committed Sep 27, 2024
1 parent 8237e23 commit c05e586
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 81 deletions.
7 changes: 5 additions & 2 deletions jest/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const nodeFiles = /[\\/]metro(?:-[^/]*)[\\/]/;
// hook. This is used below to configure babelTransformSync under Jest.
const {only: _, ...nodeBabelOptions} = metroBabelRegister.config([]);

// Register Babel for loading metro-transform-plugins in fbsource.
metroBabelRegister(['metro-transform-plugins']);
const metroTransformPlugins = require('metro-transform-plugins');

// Register Babel to allow the transformer itself to be loaded from source.
require('../scripts/build/babel-register').registerForMonorepo();
const transformer = require('@react-native/metro-babel-transformer');
Expand Down Expand Up @@ -88,8 +92,7 @@ module.exports = {
ast: true,
retainLines: true,
plugins: [
// TODO(moti): Replace with require('metro-transform-plugins').inlineRequiresPlugin when available in OSS
require('babel-preset-fbjs/plugins/inline-requires'),
metroTransformPlugins.inlineRequiresPlugin,
babelPluginPreventBabelRegister,
],
sourceType: 'module',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"babel-plugin-syntax-hermes-parser": "0.23.1",
"babel-plugin-transform-define": "^2.1.4",
"babel-plugin-transform-flow-enums": "^0.0.2",
"babel-preset-fbjs": "^3.4.0",
"chalk": "^4.0.0",
"clang-format": "^1.8.0",
"connect": "^3.6.5",
Expand Down Expand Up @@ -88,6 +87,7 @@
"jscodeshift": "^0.14.0",
"metro-babel-register": "^0.80.10",
"metro-memory-fs": "^0.80.10",
"metro-transform-plugins": "^0.80.10",
"micromatch": "^4.0.4",
"node-fetch": "^2.2.0",
"nullthrows": "^1.1.1",
Expand Down
Loading

0 comments on commit c05e586

Please sign in to comment.