Skip to content

Commit 2c3a22a

Browse files
vzaidmanfacebook-github-bot
authored andcommitted
update babel and fix tests accordingly (#1343)
Summary: X-link: facebook/react-native#46295 Pull Request resolved: #1343 Updated all **babel** packages in all `package.json` across the repo and ran `npx yarn-deduplicate yarn.lock --scopes babel`. Afterwards, fixed the following issues appearing as a result of that (squashed the following initially separate diffs to make this packages update work atomically): ### (D61336392) updated jest snapshot tests failing ### (D61336393) updated babel types and corrected typings accordingly The latest babel 7 introduces the following features we need to adjust our types to: * `JSXNamespacedName` is removed from valid `CallExpression` args ([PR](babel/babel#16421)) * `JSXNamespacedName` is used for namespaced XML properties in things like `<div namespace:name="value">`, but `fn(namespace:name)` doesn't make any sense. * Dynamic imports are enabled behind a new flag `createImportExpressions` ([PR](babel/babel#15682)), introducing calls such as `import(foo, options)`. These complicate the expected values passed to `import` to be more than just strings. * Since these are behind a flag that is not expected to be enabled, we can throw an error for now and whoever uses it can add a support to it if needed later. ### Added a new metro ENV ignore `BROWSERSLIST_ROOT_PATH` is set to `""` explicitly in `xplat/js/BUCK` and then ignored in `js/tools/metro-buck-transform-worker/src/EnvVarAllowList.js` Reviewed By: robhogan Differential Revision: D61543660 fbshipit-source-id: abbcab72642cf6dc03eed5142eb78dbcc7f63a86
1 parent 71c6bb5 commit 2c3a22a

File tree

19 files changed

+801
-1042
lines changed

19 files changed

+801
-1042
lines changed

flow-typed/npm/babel-traverse_v7.x.x.js

+9
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,9 @@ declare module '@babel/traverse' {
900900
isImportAttribute(opts?: Opts): boolean;
901901
isImportDeclaration(opts?: Opts): boolean;
902902
isImportDefaultSpecifier(opts?: Opts): boolean;
903+
isImportExpression(opts?: Opts): boolean;
903904
isImportNamespaceSpecifier(opts?: Opts): boolean;
905+
isImportOrExportDeclaration(opts?: Opts): boolean;
904906
isImportSpecifier(opts?: Opts): boolean;
905907
isIndexedAccessType(opts?: Opts): boolean;
906908
isInferredPredicate(opts?: Opts): boolean;
@@ -1215,7 +1217,9 @@ declare module '@babel/traverse' {
12151217
assertImportAttribute(opts?: Opts): void;
12161218
assertImportDeclaration(opts?: Opts): void;
12171219
assertImportDefaultSpecifier(opts?: Opts): void;
1220+
assertImportExpression(opts?: Opts): void;
12181221
assertImportNamespaceSpecifier(opts?: Opts): void;
1222+
assertImportOrExportDeclaration(opts?: Opts): void;
12191223
assertImportSpecifier(opts?: Opts): void;
12201224
assertIndexedAccessType(opts?: Opts): void;
12211225
assertInferredPredicate(opts?: Opts): void;
@@ -1571,10 +1575,15 @@ declare module '@babel/traverse' {
15711575
ImportAttribute?: VisitNode<BabelNodeImportAttribute, TState>,
15721576
ImportDeclaration?: VisitNode<BabelNodeImportDeclaration, TState>,
15731577
ImportDefaultSpecifier?: VisitNode<BabelNodeImportDefaultSpecifier, TState>,
1578+
ImportExpression?: VisitNode<BabelNodeImportExpression, TState>,
15741579
ImportNamespaceSpecifier?: VisitNode<
15751580
BabelNodeImportNamespaceSpecifier,
15761581
TState,
15771582
>,
1583+
ImportOrExportDeclaration?: VisitNode<
1584+
BabelNodeImportOrExportDeclaration,
1585+
TState,
1586+
>,
15781587
ImportSpecifier?: VisitNode<BabelNodeImportSpecifier, TState>,
15791588
IndexedAccessType?: VisitNode<BabelNodeIndexedAccessType, TState>,
15801589
InferredPredicate?: VisitNode<BabelNodeInferredPredicate, TState>,

flow-typed/npm/babel-types_v7.x.x.js

+58-37
Large diffs are not rendered by default.

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"private": true,
33
"devDependencies": {
4-
"@babel/core": "^7.20.0",
5-
"@babel/plugin-syntax-class-properties": "^7.0.0",
6-
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
7-
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
8-
"@babel/plugin-transform-react-jsx": "^7.0.0",
4+
"@babel/core": "^7.25.2",
5+
"@babel/plugin-syntax-class-properties": "^7.12.13",
6+
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
7+
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
8+
"@babel/plugin-transform-react-jsx": "^7.25.2",
9+
"@babel/types": "^7.25.2",
910
"@tsconfig/node18": "1.0.1",
1011
"@typescript-eslint/eslint-plugin": "^7.1.1",
1112
"@typescript-eslint/parser": "^7.1.1",

packages/metro-babel-register/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"url": "[email protected]:facebook/metro.git"
99
},
1010
"dependencies": {
11-
"@babel/core": "^7.20.0",
11+
"@babel/core": "^7.25.2",
1212
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
13-
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
14-
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
15-
"@babel/preset-typescript": "^7.18.0",
16-
"@babel/register": "^7.0.0",
13+
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
14+
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
15+
"@babel/preset-typescript": "^7.24.7",
16+
"@babel/register": "^7.24.6",
1717
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
1818
"babel-plugin-syntax-hermes-parser": "0.23.1",
1919
"babel-plugin-transform-flow-enums": "^0.0.2",

packages/metro-babel-transformer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"license": "MIT",
1919
"dependencies": {
20-
"@babel/core": "^7.20.0",
20+
"@babel/core": "^7.25.2",
2121
"flow-enums-runtime": "^0.0.6",
2222
"hermes-parser": "0.23.1",
2323
"nullthrows": "^1.1.1"

packages/metro-runtime/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"flow-enums-runtime": "^0.0.6"
1818
},
1919
"devDependencies": {
20-
"@babel/core": "^7.20.0",
20+
"@babel/core": "^7.25.2",
2121
"react": "19.0.0-rc-fb9a90fa48-20240614",
2222
"react-refresh": "^0.14.0",
2323
"react-test-renderer": "19.0.0-rc-fb9a90fa48-20240614"

packages/metro-source-map/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"cleanup-release": "test ! -e build && mv src build && mv src.real src"
1313
},
1414
"dependencies": {
15-
"@babel/traverse": "^7.20.0",
16-
"@babel/traverse--for-generate-function-map": "npm:@babel/traverse@^7.20.0",
17-
"@babel/types": "^7.20.0",
15+
"@babel/traverse": "^7.25.3",
16+
"@babel/traverse--for-generate-function-map": "npm:@babel/traverse@^7.25.3",
17+
"@babel/types": "^7.25.2",
1818
"flow-enums-runtime": "^0.0.6",
1919
"invariant": "^2.2.4",
2020
"metro-symbolicate": "0.80.11",
@@ -25,8 +25,8 @@
2525
},
2626
"license": "MIT",
2727
"devDependencies": {
28-
"@babel/core": "^7.20.0",
29-
"@babel/parser": "^7.20.0",
28+
"@babel/core": "^7.25.2",
29+
"@babel/parser": "^7.25.3",
3030
"terser": "^5.15.0"
3131
},
3232
"engines": {

packages/metro-transform-plugins/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
},
1414
"license": "MIT",
1515
"dependencies": {
16-
"@babel/core": "^7.20.0",
17-
"@babel/generator": "^7.20.0",
18-
"@babel/template": "^7.0.0",
19-
"@babel/traverse": "^7.20.0",
16+
"@babel/core": "^7.25.2",
17+
"@babel/generator": "^7.25.0",
18+
"@babel/template": "^7.25.0",
19+
"@babel/traverse": "^7.25.3",
2020
"flow-enums-runtime": "^0.0.6",
2121
"nullthrows": "^1.1.1"
2222
},
2323
"devDependencies": {
24-
"@babel/code-frame": "^7.0.0",
25-
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.0.0",
26-
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
27-
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
28-
"@babel/types": "^7.20.0",
24+
"@babel/code-frame": "^7.24.7",
25+
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
26+
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
27+
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
28+
"@babel/types": "^7.25.2",
2929
"babel-plugin-tester": "^6.0.1",
3030
"metro": "0.80.11"
3131
},

packages/metro-transform-plugins/src/__tests__/inline-requires-plugin-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ describe('inline-requires', () => {
276276
['import Imported from "foo";', 'console.log(Imported);'],
277277
[
278278
'var _foo = _interopRequireDefault(require("foo"));',
279-
'function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }',
279+
'function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }',
280280
'console.log(_foo.default);',
281281
],
282282
);

packages/metro-transform-plugins/src/utils/createInlinePlatformChecks.js

-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ function createInlinePlatformChecks(
163163
args: Array<
164164
| BabelNodeExpression
165165
| BabelNodeSpreadElement
166-
| BabelNodeJSXNamespacedName
167166
| BabelNodeArgumentPlaceholder,
168167
>,
169168
dependencyId: string,

packages/metro-transform-worker/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
},
1414
"license": "MIT",
1515
"dependencies": {
16-
"@babel/core": "^7.20.0",
17-
"@babel/generator": "^7.20.0",
18-
"@babel/parser": "^7.20.0",
19-
"@babel/types": "^7.20.0",
16+
"@babel/core": "^7.25.2",
17+
"@babel/generator": "^7.25.0",
18+
"@babel/parser": "^7.25.3",
19+
"@babel/types": "^7.25.2",
2020
"flow-enums-runtime": "^0.0.6",
2121
"metro": "0.80.11",
2222
"metro-babel-transformer": "0.80.11",

0 commit comments

Comments
 (0)