Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #110 from WordPress/build-test-script-with-webpack
Browse files Browse the repository at this point in the history
Build the stress testing script with webpack instead of esbuild
  • Loading branch information
cbravobernal authored Nov 30, 2022
2 parents cb2625c + 0ccf1da commit 28638b6
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 230 deletions.
184 changes: 0 additions & 184 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "build/index.js",
"scripts": {
"build": "webpack --mode=production",
"build:benchmark": "esbuild benchmark/hydrationScript.js --bundle --outfile=build/hydrationScriptForTesting.js",
"build:benchmark": "webpack --mode=development",
"start": "webpack --mode=development --watch",
"benchmark": "npm run build:benchmark && node ./benchmark/index.mjs",
"dev": "npm start",
Expand Down Expand Up @@ -36,7 +36,6 @@
"@wordpress/scripts": "^24.3.0",
"babel-jest": "^28.1.0",
"csv-parse": "^5.3.1",
"esbuild": "^0.15.12",
"jest": "^28.1.0",
"minimist": "^1.2.7",
"playwright": "^1.27.1",
Expand Down
129 changes: 85 additions & 44 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,95 @@
const { resolve } = require('path');

module.exports = {
entry: {
runtime: './src/runtime',
},
output: {
filename: '[name].js',
path: resolve(process.cwd(), 'build'),
},
optimization: {
runtimeChunk: {
name: 'vendors',
module.exports = [
{
entry: {
runtime: './src/runtime',
},
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
minSize: 0,
chunks: 'all',
output: {
filename: '[name].js',
path: resolve(process.cwd(), 'build'),
},
optimization: {
runtimeChunk: {
name: 'vendors',
},
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
minSize: 0,
chunks: 'all',
},
},
},
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
cacheDirectory:
process.env.BABEL_CACHE_DIRECTORY || true,
babelrc: false,
configFile: false,
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic',
importSource: 'preact',
},
],
],
},
},
],
},
],
},
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
cacheDirectory:
process.env.BABEL_CACHE_DIRECTORY || true,
babelrc: false,
configFile: false,
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic',
importSource: 'preact',
},
{
entry: {
hydrationScriptForTesting: './benchmark/hydrationScript.js',
},
output: {
filename: '[name].js',
path: resolve(process.cwd(), 'build'),
},
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
cacheDirectory:
process.env.BABEL_CACHE_DIRECTORY || true,
babelrc: false,
configFile: false,
presets: [
[
'@babel/preset-env',
{
targets: {
esmodules: true,
},
},
],
],
],
},
},
},
],
},
],
],
},
],
},
},
};
];

0 comments on commit 28638b6

Please sign in to comment.