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
2 changes: 1 addition & 1 deletion .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
7 changes: 6 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
41 changes: 36 additions & 5 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 @@ -80,8 +80,25 @@ const build = async (tempPath, manifestPath, envExtension = {}) => {

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 +137,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 +185,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
20 changes: 20 additions & 0 deletions packages/react-devtools-extensions/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TerserPlugin = require('terser-webpack-plugin');
const {GITHUB_URL, getVersionString} = require('./utils');
const {resolveFeatureFlags} = require('react-devtools-shared/buildUtils');
const SourceMapIgnoreListPlugin = require('react-devtools-shared/SourceMapIgnoreListPlugin');
const {StatsWriterPlugin} = require('webpack-stats-plugin');

const NODE_ENV = process.env.NODE_ENV;
if (!NODE_ENV) {
Expand Down Expand Up @@ -37,6 +38,21 @@ const IS_INTERNAL_MCP_BUILD = process.env.IS_INTERNAL_MCP_BUILD === 'true';

const featureFlagTarget = process.env.FEATURE_FLAG_TARGET || 'extension-oss';

let statsFileName = `webpack-stats.${featureFlagTarget}.${__DEV__ ? 'development' : 'production'}`;
if (IS_CHROME) {
statsFileName += `.chrome`;
}
if (IS_FIREFOX) {
statsFileName += `.firefox`;
}
if (IS_EDGE) {
statsFileName += `.edge`;
}
if (IS_INTERNAL_MCP_BUILD) {
statsFileName += `.mcp`;
}
statsFileName += '.json';

const babelOptions = {
configFile: resolve(
__dirname,
Expand Down Expand Up @@ -213,6 +229,10 @@ module.exports = {
);
},
},
new StatsWriterPlugin({
stats: 'verbose',
filename: statsFileName,
}),
],
module: {
defaultRules: [
Expand Down
6 changes: 2 additions & 4 deletions scripts/ci/pack_and_store_devtools_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ cd ../react-devtools-extensions
if [[ -n "$1" ]]; then
yarn build:$1
mv ./$1/build/ReactDevTools.zip ../../build/devtools/$1-extension.zip
mv ./$1/build/webpack-stats.*.json ../../build/devtools/
else
yarn build
for browser in chrome firefox edge; do
mv ./$browser/build/ReactDevTools.zip ../../build/devtools/$browser-extension.zip
mv ./$browser/build/webpack-stats.*.json ../../build/devtools/
done
fi

# Compress all DevTools artifacts into a single tarball for easy download
cd ../../build/devtools
tar -zcvf ../devtools.tgz .
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17792,6 +17792,11 @@ webpack-sources@^3.2.0, webpack-sources@^3.2.3:
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==

webpack-stats-plugin@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/webpack-stats-plugin/-/webpack-stats-plugin-1.1.3.tgz#ebcc36c8b468074ad737882e2043c1ce4b55d928"
integrity sha512-yUKYyy+e0iF/w31QdfioRKY+h3jDBRpthexBOWGKda99iu2l/wxYsI/XqdlP5IU58/0KB9CsJZgWNAl+/MPkRw==

webpack@^5.82.1:
version "5.82.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.82.1.tgz#8f38c78e53467556e8a89054ebd3ef6e9f67dbab"
Expand Down