From eaf36e3188af96ae322cd44f2c0ada839c1df158 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Wed, 30 Apr 2025 09:58:11 +0900 Subject: [PATCH] Update on "[compiler] Null out source locations where not explicitly preserved" Inspired by #32950. Specifically from https://github.com/facebook/react/issues/32950#issuecomment-2837887871, it sounds like Babel by default emits source map information for all nodes, even when they don't have a `loc` property set. Code coverage tools then pick up the synthesized source location information for this, leading to the issue described. A few google searches didn't turn up any documented way to opt-out of generating source span information, but AI tools answer that explicitly setting `node.loc = null` omits the node from source maps. This PR is a quick hack to confirm that. [ghstack-poisoned] --- .../fixtures/compiler/sourcemaps-simple.expect.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/sourcemaps-simple.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/sourcemaps-simple.expect.md index 97f2b97f40..590b3d92f4 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/sourcemaps-simple.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/sourcemaps-simple.expect.md @@ -34,11 +34,7 @@ export const Button = () => { "version": 3, "names": [ "Button", - "$", - "_c", - "t0", - "Symbol", - "for" + "t0" ], "sources": [ "sourcemaps-simple.ts" @@ -46,7 +42,7 @@ export const Button = () => { "sourcesContent": [ "// @sourceMaps\nexport const Button = () => {\n return ;\n};\n" ], - "mappings": "kDAAA;AACA,OAAO,MAAMA,MAAM,GAAGA,CAAA,YAAAC,CAAA,GAAAC,EAAA,QAAAC,EAAA,KAAAF,CAAA,QAAAG,MAAA,CAAAC,GAAA;IACbF,EAAA,UAAyB,CAAjB,QAAQ,EAAhB,MAAyB,EAAAF,CAAA,MAAAE,EAAA,SAAAA,EAAA,GAAAF,CAAA,YAAzBE,EAAyB,EACjC", + "mappings": "kDAAA;AACA,OAAO,MAAMA,MAAM,GAAGA,CAAA,K;SACb,OAAyB,CAAjB,QAAQ,EAAhB,MAAyB,C,qCAAzBC,EAAyB,C,CACjC", "ignoreList": [] } ```