metro-source-map 0.80.12 → 0.81.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro-source-map",
3
- "version": "0.80.12",
3
+ "version": "0.81.0-alpha.1",
4
4
  "description": "🚇 Source map generator for Metro.",
5
5
  "main": "src/source-map.js",
6
6
  "repository": {
@@ -12,23 +12,24 @@
12
12
  "cleanup-release": "test ! -e build && mv src build && mv src.real src"
13
13
  },
14
14
  "dependencies": {
15
- "@babel/traverse": "^7.20.0",
16
- "@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",
17
18
  "flow-enums-runtime": "^0.0.6",
18
19
  "invariant": "^2.2.4",
19
- "metro-symbolicate": "0.80.12",
20
+ "metro-symbolicate": "0.81.0-alpha.1",
20
21
  "nullthrows": "^1.1.1",
21
- "ob1": "0.80.12",
22
+ "ob1": "0.81.0-alpha.1",
22
23
  "source-map": "^0.5.6",
23
24
  "vlq": "^1.0.0"
24
25
  },
25
26
  "license": "MIT",
26
27
  "devDependencies": {
27
- "@babel/core": "^7.20.0",
28
- "@babel/parser": "^7.20.0",
28
+ "@babel/core": "^7.25.2",
29
+ "@babel/parser": "^7.25.3",
29
30
  "terser": "^5.15.0"
30
31
  },
31
32
  "engines": {
32
- "node": ">=18"
33
+ "node": ">=18.18"
33
34
  }
34
35
  }
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _traverse = _interopRequireDefault(require("@babel/traverse"));
3
+ var _traverseForGenerateFunctionMap = _interopRequireDefault(
4
+ require("@babel/traverse--for-generate-function-map")
5
+ );
4
6
  var _types = require("@babel/types");
5
- function _interopRequireDefault(obj) {
6
- return obj && obj.__esModule ? obj : { default: obj };
7
+ function _interopRequireDefault(e) {
8
+ return e && e.__esModule ? e : { default: e };
7
9
  }
8
10
  const B64Builder = require("./B64Builder");
9
11
  const t = require("@babel/types");
@@ -116,15 +118,12 @@ function getFunctionMapVisitor(context, pushMapping) {
116
118
  }
117
119
  function forEachMapping(ast, context, pushMapping) {
118
120
  const visitor = getFunctionMapVisitor(context, pushMapping);
119
- const previousCache = _traverse.default.cache.path;
120
- _traverse.default.cache.clearPath();
121
- (0, _traverse.default)(ast, {
121
+ (0, _traverseForGenerateFunctionMap.default)(ast, {
122
122
  noScope: true,
123
123
  Function: visitor,
124
124
  Program: visitor,
125
125
  Class: visitor,
126
126
  });
127
- _traverse.default.cache.path = previousCache;
128
127
  }
129
128
  const ANONYMOUS_NAME = "<anonymous>";
130
129
  function getNameForPath(path) {
@@ -17,7 +17,8 @@ import type {NodePath} from '@babel/traverse';
17
17
  import type {Node} from '@babel/types';
18
18
  import type {MetroBabelFileMetadata} from 'metro-babel-transformer';
19
19
 
20
- import traverse from '@babel/traverse';
20
+ // $FlowFixMe[cannot-resolve-module] - resolves to @babel/traverse
21
+ import traverseForGenerateFunctionMap from '@babel/traverse--for-generate-function-map';
21
22
  import {
22
23
  isAssignmentExpression,
23
24
  isClassBody,
@@ -156,7 +157,7 @@ function getFunctionMapVisitor(
156
157
  ): FunctionMapVisitor {
157
158
  const nameStack: Array<{loc: BabelNodeSourceLocation, name: string}> = [];
158
159
  let tailPos = {line: 1, column: 0};
159
- let tailName = null;
160
+ let tailName: null | string = null;
160
161
 
161
162
  function advanceToPos(pos: {column: number, line: number}) {
162
163
  if (tailPos && positionGreater(pos, tailPos)) {
@@ -222,11 +223,9 @@ function forEachMapping(
222
223
 
223
224
  // Traversing populates/pollutes the path cache (`traverse.cache.path`) with
224
225
  // values missing the `hub` property needed by Babel transformation, so we
225
- // save, clear, and restore the cache around our traversal.
226
- // See: https://github.com/facebook/metro/pull/854#issuecomment-1336499395
227
- const previousCache = traverse.cache.path;
228
- traverse.cache.clearPath();
229
- traverse(ast, {
226
+ // use a separate copy of traverse to populate a separate cache to not pollute
227
+ // the main @babel/traverse cache. See: https://github.com/facebook/metro/pull/1340
228
+ traverseForGenerateFunctionMap(ast, {
230
229
  // Our visitor doesn't care about scope
231
230
  noScope: true,
232
231
 
@@ -234,7 +233,6 @@ function forEachMapping(
234
233
  Program: visitor,
235
234
  Class: visitor,
236
235
  });
237
- traverse.cache.path = previousCache;
238
236
  }
239
237
 
240
238
  const ANONYMOUS_NAME = '<anonymous>';