Skip to content

Commit

Permalink
Substitute babel-preset-fbjs for metro-transform-plugins (facebook#46689
Browse files Browse the repository at this point in the history
)

Summary:
Pull Request resolved: facebook#46689

Resubmission of D61014834 / facebook#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 8bfd7e1 commit cdcbbdd
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 81 deletions.
14 changes: 12 additions & 2 deletions jest/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ const {
} = require('@babel/core');
const generate = require('@babel/generator').default;

if (process.env.FBSOURCE_ENV === '1') {
// If we're running in the Meta-internal monorepo, use the central Babel
// registration, which registers all of the relevant source directories
// including Metro's root.
//
// $FlowExpectedError[cannot-resolve-module] - Won't resolve in OSS
require('@fb-tools/babel-register');
}

const metroTransformPlugins = require('metro-transform-plugins');

// Files matching this pattern will be transformed with the Node JS Babel
// transformer, rather than with the React Native Babel transformer. Scripts
// intended to run through Node JS should be included here.
Expand Down Expand Up @@ -88,8 +99,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 cdcbbdd

Please sign in to comment.