[DevTools] Don't inline workers for extensions (#34508)

This commit is contained in:
Sebastian "Sebbie" Silbermann 2025-09-17 17:59:55 +02:00 committed by GitHub
parent e3c9656d20
commit 128abcfa01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 35 additions and 16 deletions

View File

@ -201,5 +201,5 @@ jobs:
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: screenshots name: screenshots
path: ./tmp/screenshots path: ./tmp/playwright-artifacts
if-no-files-found: warn if-no-files-found: warn

View File

@ -831,6 +831,12 @@ jobs:
- run: ./scripts/ci/run_devtools_e2e_tests.js - run: ./scripts/ci/run_devtools_e2e_tests.js
env: env:
RELEASE_CHANNEL: experimental RELEASE_CHANNEL: experimental
- name: Archive Playwright report
uses: actions/upload-artifact@v4
with:
name: devtools-playwright-artifacts
path: tmp/playwright-artifacts
if-no-files-found: warn
# ----- SIZEBOT ----- # ----- SIZEBOT -----
sizebot: sizebot:

1
.gitignore vendored
View File

@ -23,6 +23,7 @@ chrome-user-data
.vscode .vscode
*.swp *.swp
*.swo *.swo
/tmp
packages/react-devtools-core/dist packages/react-devtools-core/dist
packages/react-devtools-extensions/chrome/build packages/react-devtools-extensions/chrome/build

View File

@ -108,6 +108,7 @@ module.exports = {
{ {
loader: 'workerize-loader', loader: 'workerize-loader',
options: { options: {
// Workers would have to be exposed on a public path in order to outline them.
inline: true, inline: true,
name: '[name]', name: '[name]',
}, },

View File

@ -24,6 +24,7 @@ import {
normalizeUrlIfValid, normalizeUrlIfValid,
} from 'react-devtools-shared/src/utils'; } from 'react-devtools-shared/src/utils';
import {checkConditions} from 'react-devtools-shared/src/devtools/views/Editor/utils'; import {checkConditions} from 'react-devtools-shared/src/devtools/views/Editor/utils';
import * as parseHookNames from 'react-devtools-shared/src/hooks/parseHookNames';
import { import {
setBrowserSelectionFromReact, setBrowserSelectionFromReact,
@ -40,6 +41,12 @@ import getProfilingFlags from './getProfilingFlags';
import debounce from './debounce'; import debounce from './debounce';
import './requestAnimationFramePolyfill'; import './requestAnimationFramePolyfill';
const resolvedParseHookNames = Promise.resolve(parseHookNames);
// DevTools assumes this is a dynamically imported module. Since we outline
// workers in this bundle, we can sync require the module since it's just a thin
// wrapper around calling the worker.
const hookNamesModuleLoaderFunction = () => resolvedParseHookNames;
function createBridge() { function createBridge() {
bridge = new Bridge({ bridge = new Bridge({
listen(fn) { listen(fn) {
@ -188,12 +195,6 @@ function createBridgeAndStore() {
); );
}; };
// TODO (Webpack 5) Hopefully we can remove this prop after the Webpack 5 migration.
const hookNamesModuleLoaderFunction = () =>
import(
/* webpackChunkName: 'parseHookNames' */ 'react-devtools-shared/src/hooks/parseHookNames'
);
root = createRoot(document.createElement('div')); root = createRoot(document.createElement('div'));
render = (overrideTab = mostRecentOverrideTab) => { render = (overrideTab = mostRecentOverrideTab) => {

View File

@ -261,7 +261,7 @@ module.exports = {
{ {
loader: 'workerize-loader', loader: 'workerize-loader',
options: { options: {
inline: true, inline: false,
name: '[name]', name: '[name]',
}, },
}, },

View File

@ -101,6 +101,7 @@ module.exports = {
{ {
loader: 'workerize-loader', loader: 'workerize-loader',
options: { options: {
// Workers would have to be exposed on a public path in order to outline them.
inline: true, inline: true,
name: '[name]', name: '[name]',
}, },

View File

@ -93,6 +93,7 @@ module.exports = {
{ {
loader: 'workerize-loader', loader: 'workerize-loader',
options: { options: {
// Workers would have to be exposed on a public path in order to outline them.
inline: true, inline: true,
name: '[name]', name: '[name]',
}, },

View File

@ -9,7 +9,7 @@ const ROOT_PATH = join(__dirname, '..', '..');
const reactVersion = process.argv[2]; const reactVersion = process.argv[2];
const inlinePackagePath = join(ROOT_PATH, 'packages', 'react-devtools-inline'); const inlinePackagePath = join(ROOT_PATH, 'packages', 'react-devtools-inline');
const shellPackagePath = join(ROOT_PATH, 'packages', 'react-devtools-shell'); const shellPackagePath = join(ROOT_PATH, 'packages', 'react-devtools-shell');
const screenshotPath = join(ROOT_PATH, 'tmp', 'screenshots'); const playwrightArtifactsPath = join(ROOT_PATH, 'tmp', 'playwright-artifacts');
const {SUCCESSFUL_COMPILATION_MESSAGE} = require( const {SUCCESSFUL_COMPILATION_MESSAGE} = require(
join(shellPackagePath, 'constants.js') join(shellPackagePath, 'constants.js')
@ -125,14 +125,22 @@ function runTestShell() {
async function runEndToEndTests() { async function runEndToEndTests() {
logBright('Running e2e tests'); logBright('Running e2e tests');
if (!reactVersion) { if (!reactVersion) {
testProcess = spawn('yarn', ['test:e2e', `--output=${screenshotPath}`], { testProcess = spawn(
cwd: inlinePackagePath, 'yarn',
}); ['test:e2e', `--output=${playwrightArtifactsPath}`],
{
cwd: inlinePackagePath,
}
);
} else { } else {
testProcess = spawn('yarn', ['test:e2e', `--output=${screenshotPath}`], { testProcess = spawn(
cwd: inlinePackagePath, 'yarn',
env: {...process.env, REACT_VERSION: reactVersion}, ['test:e2e', `--output=${playwrightArtifactsPath}`],
}); {
cwd: inlinePackagePath,
env: {...process.env, REACT_VERSION: reactVersion},
}
);
} }
testProcess.stdout.on('data', data => { testProcess.stdout.on('data', data => {