Skip to content

Commit

Permalink
Update @babel/generator to ^7.20.0, update snapshots (whitespace chan…
Browse files Browse the repository at this point in the history
…ges)

Summary:
Update `babel/generator` to the latest, which is a semver-minor update within the pre-existing range.

I'm separating this out for ease of review because it brings some noisy snapshot changes, including more granular source maps and fewer empty lines in generated output. The majority of this is a result of babel/babel#14980 (`>=7.19.4`).

This and the previous diff clear the way for a general Babel update, which is currently blocking a perf-boosting Metro PR #854.

Changelog: [Internal] Bump `babel/generator dependency` to `^7.20.0`

Reviewed By: motiz88

Differential Revision: D41438635

fbshipit-source-id: d56853169be22a2197ad53d6320ec6c1faf6b2a7
  • Loading branch information
robhogan authored and facebook-github-bot committed Nov 29, 2022
1 parent c9bf780 commit 9819b34
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 182 deletions.
2 changes: 1 addition & 1 deletion packages/metro-transform-plugins/package.json
Expand Up @@ -14,7 +14,7 @@
"license": "MIT",
"dependencies": {
"@babel/core": "^7.14.0",
"@babel/generator": "^7.14.0",
"@babel/generator": "^7.20.0",
"@babel/template": "^7.0.0",
"@babel/traverse": "^7.14.0",
"nullthrows": "^1.1.1"
Expand Down
Expand Up @@ -62,15 +62,12 @@ it('minimizes arguments given', () => {
expect(result.code).toMatchInlineSnapshot(`
"__d(function (g, _r, m, e, d) {
_r(27).foo();
(function () {
{
const r = 1; // _$$_REQUIRE will be renamed to \\"_r\\".
return r++;
}
})();
(function () {
var global = 'potato';
return global + 'tomato';
Expand Down
2 changes: 1 addition & 1 deletion packages/metro-transform-worker/package.json
Expand Up @@ -14,7 +14,7 @@
"license": "MIT",
"dependencies": {
"@babel/core": "^7.14.0",
"@babel/generator": "^7.14.0",
"@babel/generator": "^7.20.0",
"@babel/parser": "^7.14.0",
"@babel/types": "^7.20.0",
"babel-preset-fbjs": "^3.4.0",
Expand Down
Expand Up @@ -6,118 +6,122 @@ exports[`transforms a module with dependencies 1`] = `
Array [
Array [
2,
0,
2,
1,
0,
],
Array [
6,
0,
5,
0,
2,
14,
1,
12,
],
Array [
8,
0,
4,
2,
1,
13,
],
Array [
5,
2,
5,
0,
"require",
],
Array [
8,
6,
2,
2,
0,
"require",
],
Array [
8,
6,
13,
2,
7,
],
Array [
8,
6,
39,
2,
0,
14,
],
Array [
10,
0,
3,
0,
"arbitrary",
],
Array [
10,
7,
2,
3,
0,
"arbitrary",
],
Array [
10,
7,
11,
3,
9,
],
Array [
10,
7,
12,
3,
10,
"code",
],
Array [
10,
7,
16,
3,
9,
14,
],
Array [
10,
7,
17,
3,
0,
15,
],
Array [
12,
0,
8,
2,
4,
0,
],
Array [
12,
8,
6,
4,
6,
"b",
],
Array [
12,
8,
7,
4,
7,
],
Array [
12,
8,
10,
4,
10,
"require",
],
Array [
12,
8,
21,
4,
17,
],
Array [
12,
8,
45,
4,
22,
],
Array [
9,
0,
4,
23,
],
]
`;
Expand All @@ -133,13 +137,6 @@ Object {

exports[`transforms a simple module 1`] = `
Array [
Array [
2,
0,
1,
0,
"arbitrary",
],
Array [
2,
2,
Expand All @@ -164,13 +161,19 @@ Array [
2,
16,
1,
9,
14,
],
Array [
2,
17,
1,
15,
],
Array [
3,
0,
1,
15,
],
]
`;
Expand All @@ -186,13 +189,6 @@ Object {

exports[`transforms a simple script 1`] = `
Array [
Array [
2,
0,
1,
0,
"someReallyArbitrary",
],
Array [
2,
2,
Expand All @@ -217,13 +213,19 @@ Array [
2,
26,
1,
19,
24,
],
Array [
2,
27,
1,
25,
],
Array [
3,
0,
1,
25,
],
]
`;
Expand All @@ -240,18 +242,14 @@ Object {
exports[`transforms an es module with asyncToGenerator 1`] = `
"__d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
var _interopRequireDefault = _$$_REQUIRE(_dependencyMap[0], \\"@babel/runtime/helpers/interopRequireDefault\\");
Object.defineProperty(exports, \\"__esModule\\", {
value: true
});
exports.test = test;
var _asyncToGenerator2 = _interopRequireDefault(_$$_REQUIRE(_dependencyMap[1], \\"@babel/runtime/helpers/asyncToGenerator\\"));
function test() {
return _test.apply(this, arguments);
}
function _test() {
_test = (0, _asyncToGenerator2.default)(function* () {});
return _test.apply(this, arguments);
Expand All @@ -272,20 +270,15 @@ Object {
exports[`transforms async generators 1`] = `
"__d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
var _interopRequireDefault = _$$_REQUIRE(_dependencyMap[0], \\"@babel/runtime/helpers/interopRequireDefault\\");
Object.defineProperty(exports, \\"__esModule\\", {
value: true
});
exports.test = test;
var _awaitAsyncGenerator2 = _interopRequireDefault(_$$_REQUIRE(_dependencyMap[1], \\"@babel/runtime/helpers/awaitAsyncGenerator\\"));
var _wrapAsyncGenerator2 = _interopRequireDefault(_$$_REQUIRE(_dependencyMap[2], \\"@babel/runtime/helpers/wrapAsyncGenerator\\"));
function test() {
return _test.apply(this, arguments);
}
function _test() {
_test = (0, _wrapAsyncGenerator2.default)(function* () {
yield \\"ok\\";
Expand All @@ -299,7 +292,7 @@ exports[`transforms import/export syntax when experimental flag is on 1`] = `
Array [
Array [
4,
0,
2,
1,
0,
],
Expand All @@ -314,7 +307,13 @@ Array [
4,
7,
1,
8,
],
Array [
5,
0,
1,
20,
],
]
`;
Expand Down
6 changes: 1 addition & 5 deletions packages/metro-transform-worker/src/__tests__/index-test.js
Expand Up @@ -159,13 +159,9 @@ it('transforms a module with dependencies', async () => {
' "use strict";',
'',
' var _interopRequireDefault = _$$_REQUIRE(_dependencyMap[0], "@babel/runtime/helpers/interopRequireDefault");',
'',
' var _c = _interopRequireDefault(_$$_REQUIRE(_dependencyMap[1], "./c"));',
'',
' _$$_REQUIRE(_dependencyMap[2], "./a");',
'',
' arbitrary(code);',
'',
' var b = _$$_REQUIRE(_dependencyMap[3], "b");',
'});',
].join('\n'),
Expand Down Expand Up @@ -198,7 +194,7 @@ it('transforms an es module with asyncToGenerator', async () => {

expect(result.output[0].type).toBe('js/module');
expect(result.output[0].data.code).toMatchSnapshot();
expect(result.output[0].data.map).toHaveLength(6);
expect(result.output[0].data.map).toHaveLength(13);
expect(result.output[0].data.functionMap).toMatchSnapshot();
expect(result.dependencies).toEqual([
{
Expand Down
2 changes: 1 addition & 1 deletion packages/metro/package.json
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/core": "^7.14.0",
"@babel/generator": "^7.14.0",
"@babel/generator": "^7.20.0",
"@babel/parser": "^7.14.0",
"@babel/template": "^7.0.0",
"@babel/traverse": "^7.14.0",
Expand Down
Expand Up @@ -17,7 +17,6 @@ exports[`Util generates a remote asset for a given descriptor 1`] = `
pickScale,
getUrlCacheBreaker
} = require(\\"react-native-module/asset-utils\\");
module.exports = {
\\"width\\": 240,
\\"height\\": 24,
Expand Down

0 comments on commit 9819b34

Please sign in to comment.