From 45d942f94a5aa40e9f809b41325c31c799a29216 Mon Sep 17 00:00:00 2001 From: lauren Date: Thu, 17 Apr 2025 13:11:55 -0400 Subject: [PATCH 1/4] [mcp] Also emit bailout messages with no loc (#32937) Not every bailout will contain a loc (could be synthetic) --- .../packages/react-mcp-server/src/index.ts | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts index 864b8242eb..6938c3ee64 100644 --- a/compiler/packages/react-mcp-server/src/index.ts +++ b/compiler/packages/react-mcp-server/src/index.ts @@ -158,7 +158,7 @@ server.tool( } } }; - const errors: Array<{message: string; loc: SourceLocation}> = []; + const errors: Array<{message: string; loc: SourceLocation | null}> = []; const compilerOptions: Partial = { panicThreshold: 'none', logger: { @@ -170,12 +170,10 @@ server.tool( detail.loc == null || typeof detail.loc == 'symbol' ? event.fnLoc : detail.loc; - if (loc != null) { - errors.push({ - message: detail.reason, - loc, - }); - } + errors.push({ + message: detail.reason, + loc, + }); } }, }, @@ -279,17 +277,16 @@ server.tool( } } if (errors.length > 0) { - const errMessages = errors.map(err => { - if (typeof err.loc !== 'symbol') { + return { + content: errors.map(err => { return { type: 'text' as const, - text: `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`, + text: + err.loc === null || typeof err.loc === 'symbol' + ? `React Compiler bailed out:\n\n${err.message}` + : `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`, }; - } - return null; - }); - return { - content: errMessages.filter(msg => msg !== null), + }), }; } return { From ce578f9c59be73e6e32c633e6d251e8ec6dcad84 Mon Sep 17 00:00:00 2001 From: lauren Date: Thu, 17 Apr 2025 13:13:50 -0400 Subject: [PATCH 2/4] [compiler] Update publish tags (#32952) Adds missing tag. --- compiler/scripts/release/publish.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/scripts/release/publish.js b/compiler/scripts/release/publish.js index 23ca530062..40f70ec313 100755 --- a/compiler/scripts/release/publish.js +++ b/compiler/scripts/release/publish.js @@ -62,7 +62,7 @@ async function main() { .option('tag', { description: 'Tag to publish to npm', type: 'choices', - choices: ['experimental', 'beta'], + choices: ['experimental', 'beta', 'rc'], default: 'experimental', }) .option('version-name', { From bc6184dd993e6ea0efdee7553293676db774c3ca Mon Sep 17 00:00:00 2001 From: "Sebastian \"Sebbie\" Silbermann" Date: Thu, 17 Apr 2025 21:56:05 +0200 Subject: [PATCH 3/4] [devtools] Fix "View source" for sources with URLs that aren't normalized (#32951) --- .../src/main/fetchFileWithCaching.js | 4 ++-- .../react-devtools-extensions/src/main/index.js | 7 ++++++- .../react-devtools-shared/src/symbolicateSource.js | 4 +--- packages/react-devtools-shared/src/utils.js | 14 +++++++++++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js b/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js index 67725e27d8..97bf1fe35b 100644 --- a/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js +++ b/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js @@ -1,6 +1,6 @@ /* global chrome */ -import {normalizeUrl} from 'react-devtools-shared/src/utils'; +import {normalizeUrlIfValid} from 'react-devtools-shared/src/utils'; import {__DEBUG__} from 'react-devtools-shared/src/constants'; let debugIDCounter = 0; @@ -117,7 +117,7 @@ async function fetchFileWithCaching(url: string): Promise { chrome.devtools.inspectedWindow.getResources(r => resolve(r)), ); - const normalizedReferenceURL = normalizeUrl(url); + const normalizedReferenceURL = normalizeUrlIfValid(url); const resource = resources.find(r => r.url === normalizedReferenceURL); if (resource != null) { diff --git a/packages/react-devtools-extensions/src/main/index.js b/packages/react-devtools-extensions/src/main/index.js index 7d94449fcc..63d2581953 100644 --- a/packages/react-devtools-extensions/src/main/index.js +++ b/packages/react-devtools-extensions/src/main/index.js @@ -16,6 +16,7 @@ import { LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY, } from 'react-devtools-shared/src/constants'; import {logEvent} from 'react-devtools-shared/src/Logger'; +import {normalizeUrlIfValid} from 'react-devtools-shared/src/utils'; import { setBrowserSelectionFromReact, @@ -128,7 +129,11 @@ function createBridgeAndStore() { : source; // We use 1-based line and column, Chrome expects them 0-based. - chrome.devtools.panels.openResource(sourceURL, line - 1, column - 1); + chrome.devtools.panels.openResource( + normalizeUrlIfValid(sourceURL), + line - 1, + column - 1, + ); }; // TODO (Webpack 5) Hopefully we can remove this prop after the Webpack 5 migration. diff --git a/packages/react-devtools-shared/src/symbolicateSource.js b/packages/react-devtools-shared/src/symbolicateSource.js index 9430e88b3f..6504ab2594 100644 --- a/packages/react-devtools-shared/src/symbolicateSource.js +++ b/packages/react-devtools-shared/src/symbolicateSource.js @@ -7,7 +7,6 @@ * @flow */ -import {normalizeUrl} from 'react-devtools-shared/src/utils'; import SourceMapConsumer from 'react-devtools-shared/src/hooks/SourceMapConsumer'; import type {Source} from 'react-devtools-shared/src/shared/types'; @@ -91,9 +90,8 @@ export async function symbolicateSource( try { // sourceMapURL = https://react.dev/script.js.map void new URL(possiblyURL); // test if it is a valid URL - const normalizedURL = normalizeUrl(possiblyURL); - return {sourceURL: normalizedURL, line, column}; + return {sourceURL: possiblyURL, line, column}; } catch (e) { // This is not valid URL if ( diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js index 12c9fb739c..b0a8f5c53e 100644 --- a/packages/react-devtools-shared/src/utils.js +++ b/packages/react-devtools-shared/src/utils.js @@ -996,9 +996,17 @@ export function backendToFrontendSerializedElementMapper( }; } -// Chrome normalizes urls like webpack-internals:// but new URL don't, so cannot use new URL here. -export function normalizeUrl(url: string): string { - return url.replace('/./', '/'); +/** + * Should be used when treating url as a Chrome Resource URL. + */ +export function normalizeUrlIfValid(url: string): string { + try { + // TODO: Chrome will use the basepath to create a Resource URL. + return new URL(url).toString(); + } catch { + // Giving up if it's not a valid URL without basepath + return url; + } } export function getIsReloadAndProfileSupported(): boolean { From cd17b4c1838a542fd9b50f71b37c37002a33092a Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 21 Apr 2025 13:42:52 -0400 Subject: [PATCH 4/4] [ci] Remove compiler weekly release No longer needed. --- .../workflows/compiler_prereleases_weekly.yml | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 .github/workflows/compiler_prereleases_weekly.yml diff --git a/.github/workflows/compiler_prereleases_weekly.yml b/.github/workflows/compiler_prereleases_weekly.yml deleted file mode 100644 index 72af00d521..0000000000 --- a/.github/workflows/compiler_prereleases_weekly.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: (Compiler) Publish Prereleases Weekly - -on: - schedule: - # At 10 minutes past 9:00 on Mon - - cron: 10 9 * * 1 - -permissions: {} - -env: - TZ: /usr/share/zoneinfo/America/Los_Angeles - -jobs: - publish_prerelease_beta: - name: Publish to beta channel - uses: facebook/react/.github/workflows/compiler_prereleases.yml@main - with: - commit_sha: ${{ github.sha }} - release_channel: beta - dist_tag: beta - version_name: '19.0.0' - secrets: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }}