Skip to content

Commit 128abcf

Browse files
authored
[DevTools] Don't inline workers for extensions (facebook#34508)
1 parent e3c9656 commit 128abcf

File tree

9 files changed

+35
-16
lines changed

9 files changed

+35
-16
lines changed

.github/workflows/devtools_regression_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,5 @@ jobs:
201201
- uses: actions/upload-artifact@v4
202202
with:
203203
name: screenshots
204-
path: ./tmp/screenshots
204+
path: ./tmp/playwright-artifacts
205205
if-no-files-found: warn

.github/workflows/runtime_build_and_test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,12 @@ jobs:
831831
- run: ./scripts/ci/run_devtools_e2e_tests.js
832832
env:
833833
RELEASE_CHANNEL: experimental
834+
- name: Archive Playwright report
835+
uses: actions/upload-artifact@v4
836+
with:
837+
name: devtools-playwright-artifacts
838+
path: tmp/playwright-artifacts
839+
if-no-files-found: warn
834840

835841
# ----- SIZEBOT -----
836842
sizebot:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ chrome-user-data
2323
.vscode
2424
*.swp
2525
*.swo
26+
/tmp
2627

2728
packages/react-devtools-core/dist
2829
packages/react-devtools-extensions/chrome/build

packages/react-devtools-core/webpack.standalone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ module.exports = {
108108
{
109109
loader: 'workerize-loader',
110110
options: {
111+
// Workers would have to be exposed on a public path in order to outline them.
111112
inline: true,
112113
name: '[name]',
113114
},

packages/react-devtools-extensions/src/main/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
normalizeUrlIfValid,
2525
} from 'react-devtools-shared/src/utils';
2626
import {checkConditions} from 'react-devtools-shared/src/devtools/views/Editor/utils';
27+
import * as parseHookNames from 'react-devtools-shared/src/hooks/parseHookNames';
2728

2829
import {
2930
setBrowserSelectionFromReact,
@@ -40,6 +41,12 @@ import getProfilingFlags from './getProfilingFlags';
4041
import debounce from './debounce';
4142
import './requestAnimationFramePolyfill';
4243

44+
const resolvedParseHookNames = Promise.resolve(parseHookNames);
45+
// DevTools assumes this is a dynamically imported module. Since we outline
46+
// workers in this bundle, we can sync require the module since it's just a thin
47+
// wrapper around calling the worker.
48+
const hookNamesModuleLoaderFunction = () => resolvedParseHookNames;
49+
4350
function createBridge() {
4451
bridge = new Bridge({
4552
listen(fn) {
@@ -188,12 +195,6 @@ function createBridgeAndStore() {
188195
);
189196
};
190197

191-
// TODO (Webpack 5) Hopefully we can remove this prop after the Webpack 5 migration.
192-
const hookNamesModuleLoaderFunction = () =>
193-
import(
194-
/* webpackChunkName: 'parseHookNames' */ 'react-devtools-shared/src/hooks/parseHookNames'
195-
);
196-
197198
root = createRoot(document.createElement('div'));
198199

199200
render = (overrideTab = mostRecentOverrideTab) => {

packages/react-devtools-extensions/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ module.exports = {
261261
{
262262
loader: 'workerize-loader',
263263
options: {
264-
inline: true,
264+
inline: false,
265265
name: '[name]',
266266
},
267267
},

packages/react-devtools-fusebox/webpack.config.frontend.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ module.exports = {
101101
{
102102
loader: 'workerize-loader',
103103
options: {
104+
// Workers would have to be exposed on a public path in order to outline them.
104105
inline: true,
105106
name: '[name]',
106107
},

packages/react-devtools-inline/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ module.exports = {
9393
{
9494
loader: 'workerize-loader',
9595
options: {
96+
// Workers would have to be exposed on a public path in order to outline them.
9697
inline: true,
9798
name: '[name]',
9899
},

scripts/ci/run_devtools_e2e_tests.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ROOT_PATH = join(__dirname, '..', '..');
99
const reactVersion = process.argv[2];
1010
const inlinePackagePath = join(ROOT_PATH, 'packages', 'react-devtools-inline');
1111
const shellPackagePath = join(ROOT_PATH, 'packages', 'react-devtools-shell');
12-
const screenshotPath = join(ROOT_PATH, 'tmp', 'screenshots');
12+
const playwrightArtifactsPath = join(ROOT_PATH, 'tmp', 'playwright-artifacts');
1313

1414
const {SUCCESSFUL_COMPILATION_MESSAGE} = require(
1515
join(shellPackagePath, 'constants.js')
@@ -125,14 +125,22 @@ function runTestShell() {
125125
async function runEndToEndTests() {
126126
logBright('Running e2e tests');
127127
if (!reactVersion) {
128-
testProcess = spawn('yarn', ['test:e2e', `--output=${screenshotPath}`], {
129-
cwd: inlinePackagePath,
130-
});
128+
testProcess = spawn(
129+
'yarn',
130+
['test:e2e', `--output=${playwrightArtifactsPath}`],
131+
{
132+
cwd: inlinePackagePath,
133+
}
134+
);
131135
} else {
132-
testProcess = spawn('yarn', ['test:e2e', `--output=${screenshotPath}`], {
133-
cwd: inlinePackagePath,
134-
env: {...process.env, REACT_VERSION: reactVersion},
135-
});
136+
testProcess = spawn(
137+
'yarn',
138+
['test:e2e', `--output=${playwrightArtifactsPath}`],
139+
{
140+
cwd: inlinePackagePath,
141+
env: {...process.env, REACT_VERSION: reactVersion},
142+
}
143+
);
136144
}
137145

138146
testProcess.stdout.on('data', data => {

0 commit comments

Comments
 (0)