Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/devtools_regression_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: react-devtools
path: build/devtools.tgz
path: build/devtools
if-no-files-found: error
# Simplifies getting the extension for local testing
- name: Archive chrome extension
Expand Down Expand Up @@ -201,5 +201,5 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: screenshots
path: ./tmp/screenshots
path: ./tmp/playwright-artifacts
if-no-files-found: warn
13 changes: 12 additions & 1 deletion .github/workflows/runtime_build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@ jobs:
name: react-devtools-${{ matrix.browser }}-extension
path: build/devtools/${{ matrix.browser }}-extension.zip
if-no-files-found: error
- name: Archive ${{ matrix.browser }} metadata
uses: actions/upload-artifact@v4
with:
name: react-devtools-${{ matrix.browser }}-metadata
path: build/devtools/webpack-stats.*.json

merge_devtools_artifacts:
name: Merge DevTools artifacts
Expand All @@ -776,7 +781,7 @@ jobs:
uses: actions/upload-artifact/merge@v4
with:
name: react-devtools
pattern: react-devtools-*-extension
pattern: react-devtools-*

run_devtools_e2e_tests:
name: Run DevTools e2e tests
Expand Down Expand Up @@ -826,6 +831,12 @@ jobs:
- run: ./scripts/ci/run_devtools_e2e_tests.js
env:
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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ chrome-user-data
.vscode
*.swp
*.swo
/tmp

packages/react-devtools-core/dist
packages/react-devtools-extensions/chrome/build
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-core/webpack.standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ module.exports = {
{
loader: 'workerize-loader',
options: {
// Workers would have to be exposed on a public path in order to outline them.
inline: true,
name: '[name]',
},
Expand Down
49 changes: 36 additions & 13 deletions packages/react-devtools-extensions/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const archiver = require('archiver');
const {execSync} = require('child_process');
const {readFileSync, writeFileSync, createWriteStream} = require('fs');
const {copy, ensureDir, move, remove, pathExistsSync} = require('fs-extra');
const {join, resolve} = require('path');
const {join, resolve, basename} = require('path');
const {getGitCommit} = require('./utils');

// These files are copied along with Webpack-bundled files
Expand Down Expand Up @@ -66,22 +66,31 @@ const build = async (tempPath, manifestPath, envExtension = {}) => {
stdio: 'inherit',
},
);
execSync(
`${webpackPath} --config webpack.backend.js --output-path ${binPath}`,
{
cwd: __dirname,
env: mergedEnv,
stdio: 'inherit',
},
);

// Make temp dir
await ensureDir(zipPath);

const copiedManifestPath = join(zipPath, 'manifest.json');

let webpackStatsFilePath = null;
// Copy unbuilt source files to zip dir to be packaged:
await copy(binPath, join(zipPath, 'build'));
await copy(binPath, join(zipPath, 'build'), {
filter: filePath => {
if (basename(filePath).startsWith('webpack-stats.')) {
webpackStatsFilePath = filePath;
// The ZIP is the actual extension and doesn't need this metadata.
return false;
}
return true;
},
});
if (webpackStatsFilePath !== null) {
await copy(
webpackStatsFilePath,
join(tempPath, basename(webpackStatsFilePath)),
);
webpackStatsFilePath = join(tempPath, basename(webpackStatsFilePath));
}
await copy(manifestPath, copiedManifestPath);
await Promise.all(
STATIC_FILES.map(file => copy(join(__dirname, file), join(zipPath, file))),
Expand Down Expand Up @@ -120,16 +129,26 @@ const build = async (tempPath, manifestPath, envExtension = {}) => {
archive.finalize();
zipStream.on('close', () => resolvePromise());
});

return webpackStatsFilePath;
};

const postProcess = async (tempPath, destinationPath) => {
const postProcess = async (tempPath, destinationPath, webpackStatsFilePath) => {
const unpackedSourcePath = join(tempPath, 'zip');
const packedSourcePath = join(tempPath, 'ReactDevTools.zip');
const packedDestPath = join(destinationPath, 'ReactDevTools.zip');
const unpackedDestPath = join(destinationPath, 'unpacked');

await move(unpackedSourcePath, unpackedDestPath); // Copy built files to destination
await move(packedSourcePath, packedDestPath); // Copy built files to destination
if (webpackStatsFilePath !== null) {
await move(
webpackStatsFilePath,
join(destinationPath, basename(webpackStatsFilePath)),
);
} else {
console.log('No webpack-stats.json file was generated.');
}
await remove(tempPath); // Clean up temp directory and files
};

Expand Down Expand Up @@ -158,10 +177,14 @@ const main = async buildId => {
const tempPath = join(__dirname, 'build', buildId);
await ensureLocalBuild();
await preProcess(destinationPath, tempPath);
await build(tempPath, manifestPath, envExtension);
const webpackStatsFilePath = await build(
tempPath,
manifestPath,
envExtension,
);

const builtUnpackedPath = join(destinationPath, 'unpacked');
await postProcess(tempPath, destinationPath);
await postProcess(tempPath, destinationPath, webpackStatsFilePath);

return builtUnpackedPath;
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"webpack": "^5.82.1",
"webpack-cli": "^5.1.1",
"webpack-dev-server": "^4.15.0",
"webpack-stats-plugin": "^1.1.3",
"workerize-loader": "^2.0.2"
},
"dependencies": {
Expand Down
13 changes: 7 additions & 6 deletions packages/react-devtools-extensions/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
normalizeUrlIfValid,
} from 'react-devtools-shared/src/utils';
import {checkConditions} from 'react-devtools-shared/src/devtools/views/Editor/utils';
import * as parseHookNames from 'react-devtools-shared/src/hooks/parseHookNames';

import {
setBrowserSelectionFromReact,
Expand All @@ -40,6 +41,12 @@ import getProfilingFlags from './getProfilingFlags';
import debounce from './debounce';
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() {
bridge = new Bridge({
listen(fn) {
Expand Down Expand Up @@ -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'));

render = (overrideTab = mostRecentOverrideTab) => {
Expand Down
118 changes: 0 additions & 118 deletions packages/react-devtools-extensions/webpack.backend.js

This file was deleted.

Loading
Loading