Skip to content

Commit 33b78ee

Browse files
huntiefacebook-github-bot
authored andcommitted
Substitute babel-preset-fbjs for metro-transform-plugins (#46689)
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] Reviewed By: hoxyq Differential Revision: D63532211 fbshipit-source-id: e94b55b7b61194b50131b36a2fe817e149152953
1 parent 64381d3 commit 33b78ee

File tree

3 files changed

+54
-81
lines changed

3 files changed

+54
-81
lines changed

jest/preprocessor.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ const {
2323
} = require('@babel/core');
2424
const generate = require('@babel/generator').default;
2525

26+
if (process.env.FBSOURCE_ENV === '1') {
27+
// If we're running in the Meta-internal monorepo, use the central Babel
28+
// registration, which registers all of the relevant source directories
29+
// including Metro's root.
30+
//
31+
// $FlowExpectedError[cannot-resolve-module] - Won't resolve in OSS
32+
require('@fb-tools/babel-register');
33+
}
34+
35+
const metroTransformPlugins = require('metro-transform-plugins');
36+
2637
// Files matching this pattern will be transformed with the Node JS Babel
2738
// transformer, rather than with the React Native Babel transformer. Scripts
2839
// intended to run through Node JS should be included here.
@@ -88,8 +99,7 @@ module.exports = {
8899
ast: true,
89100
retainLines: true,
90101
plugins: [
91-
// TODO(moti): Replace with require('metro-transform-plugins').inlineRequiresPlugin when available in OSS
92-
require('babel-preset-fbjs/plugins/inline-requires'),
102+
metroTransformPlugins.inlineRequiresPlugin,
93103
babelPluginPreventBabelRegister,
94104
],
95105
sourceType: 'module',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"babel-plugin-syntax-hermes-parser": "0.23.1",
6060
"babel-plugin-transform-define": "^2.1.4",
6161
"babel-plugin-transform-flow-enums": "^0.0.2",
62-
"babel-preset-fbjs": "^3.4.0",
6362
"chalk": "^4.0.0",
6463
"clang-format": "^1.8.0",
6564
"connect": "^3.6.5",
@@ -88,6 +87,7 @@
8887
"jscodeshift": "^0.14.0",
8988
"metro-babel-register": "^0.80.10",
9089
"metro-memory-fs": "^0.80.10",
90+
"metro-transform-plugins": "^0.80.10",
9191
"micromatch": "^4.0.4",
9292
"node-fetch": "^2.2.0",
9393
"nullthrows": "^1.1.1",

0 commit comments

Comments
 (0)