Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update babel and fix tests accordingly #1343

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions flow-typed/npm/babel-traverse_v7.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,9 @@ declare module '@babel/traverse' {
isImportAttribute(opts?: Opts): boolean;
isImportDeclaration(opts?: Opts): boolean;
isImportDefaultSpecifier(opts?: Opts): boolean;
isImportExpression(opts?: Opts): boolean;
isImportNamespaceSpecifier(opts?: Opts): boolean;
isImportOrExportDeclaration(opts?: Opts): boolean;
isImportSpecifier(opts?: Opts): boolean;
isIndexedAccessType(opts?: Opts): boolean;
isInferredPredicate(opts?: Opts): boolean;
Expand Down Expand Up @@ -1215,7 +1217,9 @@ declare module '@babel/traverse' {
assertImportAttribute(opts?: Opts): void;
assertImportDeclaration(opts?: Opts): void;
assertImportDefaultSpecifier(opts?: Opts): void;
assertImportExpression(opts?: Opts): void;
assertImportNamespaceSpecifier(opts?: Opts): void;
assertImportOrExportDeclaration(opts?: Opts): void;
assertImportSpecifier(opts?: Opts): void;
assertIndexedAccessType(opts?: Opts): void;
assertInferredPredicate(opts?: Opts): void;
Expand Down Expand Up @@ -1571,10 +1575,15 @@ declare module '@babel/traverse' {
ImportAttribute?: VisitNode<BabelNodeImportAttribute, TState>,
ImportDeclaration?: VisitNode<BabelNodeImportDeclaration, TState>,
ImportDefaultSpecifier?: VisitNode<BabelNodeImportDefaultSpecifier, TState>,
ImportExpression?: VisitNode<BabelNodeImportExpression, TState>,
ImportNamespaceSpecifier?: VisitNode<
BabelNodeImportNamespaceSpecifier,
TState,
>,
ImportOrExportDeclaration?: VisitNode<
BabelNodeImportOrExportDeclaration,
TState,
>,
ImportSpecifier?: VisitNode<BabelNodeImportSpecifier, TState>,
IndexedAccessType?: VisitNode<BabelNodeIndexedAccessType, TState>,
InferredPredicate?: VisitNode<BabelNodeInferredPredicate, TState>,
Expand Down
95 changes: 58 additions & 37 deletions flow-typed/npm/babel-types_v7.x.x.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"private": true,
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-syntax-class-properties": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/core": "^7.25.2",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
"@babel/plugin-transform-react-jsx": "^7.25.2",
"@babel/types": "^7.25.2",
"@tsconfig/node18": "1.0.1",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/metro-babel-register/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"url": "[email protected]:facebook/metro.git"
},
"dependencies": {
"@babel/core": "^7.20.0",
"@babel/core": "^7.25.2",
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
"@babel/preset-typescript": "^7.18.0",
"@babel/register": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
"@babel/preset-typescript": "^7.24.7",
"@babel/register": "^7.24.6",
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
"babel-plugin-syntax-hermes-parser": "0.23.1",
"babel-plugin-transform-flow-enums": "^0.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/metro-babel-transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"license": "MIT",
"dependencies": {
"@babel/core": "^7.20.0",
"@babel/core": "^7.25.2",
"flow-enums-runtime": "^0.0.6",
"hermes-parser": "0.23.1",
"nullthrows": "^1.1.1"
Expand Down
9 changes: 5 additions & 4 deletions packages/metro-source-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"cleanup-release": "test ! -e build && mv src build && mv src.real src"
},
"dependencies": {
"@babel/traverse": "^7.20.0",
"@babel/types": "^7.20.0",
"@babel/traverse": "^7.25.3",
"@babel/traverse--for-generate-function-map": "npm:@babel/traverse@^7.25.3",
Copy link

@jerone jerone Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vzaidman Why was this dependency with referrer created?

Copy link

@jerone jerone Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our security tools are highlighting this as a potential security issue.

detected resolved URL for package with a different name: @babel/traverse--for-generate-function-map
    expected: @babel/traverse--for-generate-function-map
    actual: @babel/traverse

Copy link
Contributor Author

@vzaidman vzaidman Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jerone - added the info about that to the PR summary. It was introduced in #1340 - "re-implement babel traverse cache pollution bug workaround using a second copy of babel traverse".

The tool flagging it as a potential security issue is concerned about "detected resolved URL for package with a different name" but this is totally expected, so I think you can ignore or mark this concern as resolved.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. I have whitelisted this change.

The tool that giving the warning was lockfile linting: https://github.com/lirantal/lockfile-lint/tree/main/packages/lockfile-lint-api#validators

"@babel/types": "^7.25.2",
"flow-enums-runtime": "^0.0.6",
"invariant": "^2.2.4",
"metro-symbolicate": "0.80.10",
Expand All @@ -24,8 +25,8 @@
},
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/parser": "^7.20.0",
"@babel/core": "^7.25.2",
"@babel/parser": "^7.25.3",
"terser": "^5.15.0"
},
"engines": {
Expand Down
12 changes: 5 additions & 7 deletions packages/metro-source-map/src/generateFunctionMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import type {NodePath} from '@babel/traverse';
import type {Node} from '@babel/types';
import type {MetroBabelFileMetadata} from 'metro-babel-transformer';

import traverse from '@babel/traverse';
// $FlowFixMe[cannot-resolve-module] - resolves to @babel/traverse
import traverseForGenerateFunctionMap from '@babel/traverse--for-generate-function-map';
import {
isAssignmentExpression,
isClassBody,
Expand Down Expand Up @@ -222,19 +223,16 @@ function forEachMapping(

// Traversing populates/pollutes the path cache (`traverse.cache.path`) with
// values missing the `hub` property needed by Babel transformation, so we
// save, clear, and restore the cache around our traversal.
// See: https://github.com/facebook/metro/pull/854#issuecomment-1336499395
const previousCache = traverse.cache.path;
traverse.cache.clearPath();
traverse(ast, {
// use a separate copy of traverse to populate a separate cache to not pollute
// the main @babel/traverse cache. See: https://github.com/facebook/metro/pull/1340
traverseForGenerateFunctionMap(ast, {
// Our visitor doesn't care about scope
noScope: true,

Function: visitor,
Program: visitor,
Class: visitor,
});
traverse.cache.path = previousCache;
}

const ANONYMOUS_NAME = '<anonymous>';
Expand Down
18 changes: 9 additions & 9 deletions packages/metro-transform-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
},
"license": "MIT",
"dependencies": {
"@babel/core": "^7.20.0",
"@babel/generator": "^7.20.0",
"@babel/template": "^7.0.0",
"@babel/traverse": "^7.20.0",
"@babel/core": "^7.25.2",
"@babel/generator": "^7.25.0",
"@babel/template": "^7.25.0",
"@babel/traverse": "^7.25.3",
"flow-enums-runtime": "^0.0.6",
"nullthrows": "^1.1.1"
},
"devDependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
"@babel/types": "^7.20.0",
"@babel/code-frame": "^7.24.7",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
"@babel/types": "^7.25.2",
"babel-plugin-tester": "^6.0.1",
"metro": "0.80.10"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe('inline-requires', () => {
['import Imported from "foo";', 'console.log(Imported);'],
[
'var _foo = _interopRequireDefault(require("foo"));',
'function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }',
'function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }',
'console.log(_foo.default);',
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ function createInlinePlatformChecks(
args: Array<
| BabelNodeExpression
| BabelNodeSpreadElement
| BabelNodeJSXNamespacedName
| BabelNodeArgumentPlaceholder,
>,
dependencyId: string,
Expand Down
8 changes: 4 additions & 4 deletions packages/metro-transform-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
},
"license": "MIT",
"dependencies": {
"@babel/core": "^7.20.0",
"@babel/generator": "^7.20.0",
"@babel/parser": "^7.20.0",
"@babel/types": "^7.20.0",
"@babel/core": "^7.25.2",
"@babel/generator": "^7.25.0",
"@babel/parser": "^7.25.3",
"@babel/types": "^7.25.2",
"flow-enums-runtime": "^0.0.6",
"metro": "0.80.10",
"metro-babel-transformer": "0.80.10",
Expand Down
Loading
Loading