diff --git a/packages/metro-source-map/src/generateFunctionMap.js b/packages/metro-source-map/src/generateFunctionMap.js index 3e6e980bb7..7c7578a4e6 100644 --- a/packages/metro-source-map/src/generateFunctionMap.js +++ b/packages/metro-source-map/src/generateFunctionMap.js @@ -224,17 +224,15 @@ function forEachMapping( // 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, { + // @nocommit TODO: comment to the comment above ^ in the OS PR and update the comment above + const shallowCopiedAST = {...ast}; + traverse(shallowCopiedAST, { // Our visitor doesn't care about scope noScope: true, - Function: visitor, Program: visitor, Class: visitor, }); - traverse.cache.path = previousCache; } const ANONYMOUS_NAME = '';