Skip to content

Commit e787593

Browse files
committed
1 parent 2302a7b commit e787593

15 files changed

+579
-1676
lines changed

.circleci/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ jobs:
4545
rm /etc/service/{postgresql,redis}/down && sv start postgresql redis
4646
sudo -E -H -u musicbrainz carton exec -- ./script/create_test_db.sh
4747
sudo -E -H -u musicbrainz make -C po all_quiet deploy
48-
NODE_ENV=test WEBPACK_MODE=development sudo -E -H -u musicbrainz carton exec -- ./script/compile_resources.sh server web-tests
48+
NODE_ENV=test WEBPACK_MODE=development NO_PROGRESS=1 sudo -E -H -u musicbrainz carton exec -- \
49+
./script/compile_resources.sh client server web-tests
4950
sudo -E -H -u musicbrainz ./node_modules/.bin/flow --quiet
5051
sudo -E -H -u musicbrainz ./node_modules/.bin/eslint --max-warnings 0 .
5152
rm /etc/service/chrome/down && sv start chrome

docker/musicbrainz-tests/run_selenium_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ sv start artwork-indexer artwork-redirect ssssss
5252
# Compile static resources.
5353
sudo -E -H -u musicbrainz yarn
5454
sudo -E -H -u musicbrainz make -C po all_quiet deploy
55-
NODE_ENV=test WEBPACK_MODE=development \
55+
NODE_ENV=test WEBPACK_MODE=development NO_PROGRESS=1 \
5656
sudo -E -H -u musicbrainz carton exec -- ./script/compile_resources.sh
5757

5858
# Add mbtest host alias to work around NO_PROXY restriction.

docker/templates/macros.m4

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ install_javascript(`$1')
3838

3939
copy_mb(``root/ root/'')
4040
copy_mb(``script/compile_resources.sh script/dbdefs_to_js.pl script/start_renderer.pl script/xgettext.js script/'')
41-
copy_mb(``webpack.client.config.js webpack.server.config.js webpack.tests.config.js ./'')
4241
copy_mb(``webpack/ webpack/'')
4342

4443
ENV NODE_ENV production

package.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@popperjs/core": "2.5.3",
2626
"@sentry/browser": "5.10.2",
2727
"@sentry/node": "5.10.2",
28-
"babel-loader": "8.1.0",
28+
"babel-loader": "8.2.2",
2929
"balanced-match": "0.2.0",
3030
"canonical-json": "0.0.4",
3131
"cookie": "0.4.0",
@@ -35,15 +35,15 @@
3535
"filesize": "2.0.4",
3636
"generic-diff": "1.0.1",
3737
"he": "1.1.1",
38-
"imports-loader": "1.2.0",
38+
"imports-loader": "3.0.0",
3939
"jed": "git://github.com/mwiencek/Jed.git#cd3f71b",
4040
"jquery": "1.11.2",
4141
"knockout": "git://github.com/mwiencek/knockout.git#a09f077",
4242
"knockout-arraytransforms": "git://github.com/mwiencek/knockout-arraytransforms.git#9673e91",
4343
"leaflet": "1.6.0",
4444
"leaflet.markercluster": "1.4.1",
4545
"less": "4.1.1",
46-
"less-loader": "7.3.0",
46+
"less-loader": "10.0.1",
4747
"less-plugin-clean-css": "1.5.1",
4848
"leven": "2.0.0",
4949
"mutate-cow": "4.0.3",
@@ -60,10 +60,8 @@
6060
"shelljs": "0.8.4",
6161
"sliced": "1.0.1",
6262
"tablesorter": "2.31.3",
63-
"terser-webpack-plugin": "4.2.3",
64-
"webpack": "4.46.0",
65-
"webpack-cli": "3.3.12",
66-
"webpack-manifest-plugin": "2.2.0",
63+
"terser-webpack-plugin": "5.1.4",
64+
"webpack": "5.50.0",
6765
"webpack-node-externals": "3.0.0",
6866
"whatwg-fetch": "3.4.0",
6967
"yargs": "3.10.0"
@@ -72,6 +70,7 @@
7270
"@babel/cli": "7.14.8",
7371
"@babel/eslint-parser": "7.15.0",
7472
"babel-plugin-istanbul": "5.2.0",
73+
"buffer": "6.0.3",
7574
"chrome-remote-interface": "0.27.0",
7675
"eslint": "7.9.0",
7776
"eslint-plugin-fb-flow": "0.0.2",
@@ -86,7 +85,10 @@
8685
"jsdom": "13.2.0",
8786
"json5": "2.1.3",
8887
"nyc": "14.1.1",
88+
"path-browserify": "1.0.1",
89+
"process": "0.11.10",
8990
"selenium-webdriver": "4.0.0-alpha.5",
91+
"stream-browserify": "3.0.0",
9092
"tap-difflet": "0.7.2",
9193
"tap-junit": "3.1.0",
9294
"tape": "4.7.0",

root/static/scripts/common.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,12 @@ require('./common/MB/Control/SelectAll');
3838
require('./common/components/TagEditor');
3939
require('./common/components/sidebar/AcousticBrainz');
4040

41-
import(
42-
/* webpackChunkName: "common-artwork-viewer" */ './common/artworkViewer'
43-
);
44-
import(/* webpackChunkName: "common-dialogs" */ './common/dialogs');
45-
import(/* webpackChunkName: "common-filter" */ './common/components/Filter');
46-
import(/* webpackChunkName: "common-menu" */ './common/MB/Control/Menu');
47-
import(
48-
/* webpackChunkName: "common-edit-search" */ './common/MB/edit_search'
49-
);
50-
import(/* webpackChunkName: "common-ratings" */ './common/ratings');
51-
import(/* webpackChunkName: "common-tagger" */ './common/tagger');
52-
import(/* webpackChunkName: "common-cover-art" */ './common/coverart');
53-
import(/* webpackChunkName: "common-banner" */ './common/banner');
41+
import('./common/artworkViewer');
42+
import('./common/dialogs');
43+
import('./common/components/Filter');
44+
import('./common/MB/Control/Menu');
45+
import('./common/MB/edit_search');
46+
import('./common/ratings');
47+
import('./common/tagger');
48+
import('./common/coverart');
49+
import('./common/banner');

root/static/scripts/empty.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Modules that are not meant to execute the server (jQuery, Popper.js, ...)
33
* yet are imported from isomorphic components are mapped to here. See the
4-
* `NormalModuleReplacementPlugin` configuration in webpack.server.config.js.
4+
* `NormalModuleReplacementPlugin` configuration in webpack/server.config.js.
55
*
66
* The named `noop` exports prevent Webpack from warning about missing
77
* exports at build time.

script/compile_resources.sh

+7-19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ if [ -f lib/DBDefs.pm ]; then
3737
./script/dbdefs_to_js.pl
3838
fi
3939

40+
RUN_ARGS=''
4041
BUILD_CLIENT=0
4142
BUILD_SERVER=0
4243
BUILD_TESTS=0
@@ -88,37 +89,24 @@ else
8889
done
8990
fi
9091

91-
REV_MANIFEST="$BUILD_DIR/rev-manifest.json"
92-
9392
if [[ "$BUILD_CLIENT" == "1" ]]; then
94-
./node_modules/.bin/webpack --config webpack.client.config.js &
95-
check_trap_jobs
96-
97-
if [[ "$BUILD_SERVER" == "1" ]]; then
98-
sleep 5
99-
while [[ ! -f "$REV_MANIFEST" ]]; do
100-
echo 'Waiting for rev-manifest.json before building server JS ...'
101-
sleep 3
102-
done
103-
fi
93+
RUN_ARGS="$RUN_ARGS client"
10494
fi
10595

10696
if [[ "$BUILD_SERVER" == "1" ]]; then
107-
if [[ ! -f "$REV_MANIFEST" ]]; then
108-
echo '{}' > "$REV_MANIFEST"
109-
fi
110-
./node_modules/.bin/webpack --config webpack.server.config.js &
111-
check_trap_jobs
97+
RUN_ARGS="$RUN_ARGS server"
11298
fi
11399

114100
if [[ "$BUILD_TESTS" == "1" ]]; then
101+
RUN_ARGS="$RUN_ARGS tests"
115102
if ./script/database_exists TEST 2> /dev/null; then
116103
./script/dump_js_type_info.pl
117104
else
118105
echo 'Skipping typeInfo.js dump; no running TEST database?'
119106
fi
120-
./node_modules/.bin/webpack --config webpack.tests.config.js &
121-
check_trap_jobs
122107
fi
123108

109+
"$MB_SERVER_ROOT"/webpack/run.js $RUN_ARGS &
110+
check_trap_jobs
111+
124112
if [[ "$WATCH_MODE" == "1" ]]; then wait; fi

webpack/browserConfig.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ const webpack = require('webpack');
1212
const definePluginConfig = require('./definePluginConfig');
1313

1414
module.exports = {
15-
node: {
16-
fs: 'empty',
17-
path: true,
18-
},
15+
node: false,
1916

2017
plugins: [
2118
new webpack.DefinePlugin(definePluginConfig),
@@ -40,4 +37,6 @@ module.exports = {
4037
jquery$: path.resolve(__dirname, '../node_modules/jquery'),
4138
},
4239
},
40+
41+
target: ['web', 'es5'],
4342
};

webpack/cacheConfig.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (C) 2021 MetaBrainz Foundation
3+
*
4+
* This file is part of MusicBrainz, the open internet music database,
5+
* and is licensed under the GPL version 2, or (at your option) any
6+
* later version: http://www.gnu.org/licenses/gpl-2.0.txt
7+
*/
8+
9+
const path = require('path');
10+
11+
const constants = require('./constants');
12+
const dirs = require('./dirs');
13+
14+
module.exports = {
15+
type: 'filesystem',
16+
buildDependencies: {
17+
config: [path.resolve(dirs.CHECKOUT, 'webpack') + path.sep],
18+
},
19+
version: (
20+
constants.WEBPACK_MODE + '-' +
21+
String(process.env.NODE_ENV) + '-' +
22+
String(process.env.MUSICBRAINZ_RUNNING_TESTS)
23+
),
24+
};

webpack.client.config.js webpack/client.config.js

+34-31
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@
88

99
const canonicalJson = require('canonical-json');
1010
const fs = require('fs');
11-
const ManifestPlugin = require('webpack-manifest-plugin');
1211
const path = require('path');
1312
const shell = require('shelljs');
1413
const shellQuote = require('shell-quote');
1514
const TerserPlugin = require('terser-webpack-plugin');
1615
const webpack = require('webpack');
1716

18-
const poFile = require('./root/server/gettext/poFile');
19-
const browserConfig = require('./webpack/browserConfig');
17+
const poFile = require('../root/server/gettext/poFile');
18+
const {cloneObjectDeep} =
19+
require('../root/static/scripts/common/utility/cloneDeep');
20+
const jedDataTemplate = require('../root/static/scripts/jed-data');
21+
22+
const browserConfig = require('./browserConfig');
23+
const cacheConfig = require('./cacheConfig');
2024
const {
2125
dirs,
2226
GETTEXT_DOMAINS,
2327
PRODUCTION_MODE,
2428
WEBPACK_MODE,
25-
} = require('./webpack/constants');
26-
const moduleConfig = require('./webpack/moduleConfig');
27-
const providePluginConfig = require('./webpack/providePluginConfig');
28-
const {cloneObjectDeep} =
29-
require('./root/static/scripts/common/utility/cloneDeep');
30-
const jedDataTemplate = require('./root/static/scripts/jed-data');
29+
} = require('./constants');
30+
const moduleConfig = require('./moduleConfig');
31+
const providePluginConfig = require('./providePluginConfig');
3132

3233
const entries = [
3334
'account/applications/register',
@@ -212,19 +213,23 @@ plugins.push(new webpack.ProvidePlugin(providePluginConfig));
212213

213214
if (PRODUCTION_MODE) {
214215
plugins.push(
215-
new webpack.HashedModuleIdsPlugin({
216+
new webpack.ids.HashedModuleIdsPlugin({
216217
hashDigestLength: 7,
217218
}),
218219
);
219220
}
220221

221-
plugins.push.apply(plugins, [
222-
new ManifestPlugin({
223-
fileName: 'rev-manifest.json',
224-
}),
225-
]);
222+
if (String(process.env.NO_PROGRESS) !== '1') {
223+
plugins.push(
224+
new webpack.ProgressPlugin({
225+
activeModules: true,
226+
}),
227+
);
228+
}
226229

227230
module.exports = {
231+
cache: cacheConfig,
232+
228233
context: dirs.CHECKOUT,
229234

230235
devtool: 'source-map',
@@ -235,10 +240,13 @@ module.exports = {
235240

236241
module: moduleConfig,
237242

238-
node: browserConfig.node,
243+
name: 'client-bundles',
244+
245+
node: false,
239246

240247
optimization: {
241248
runtimeChunk: 'single',
249+
242250
splitChunks: {
243251
cacheGroups: {
244252
'common-chunks': {
@@ -250,6 +258,16 @@ module.exports = {
250258
},
251259
},
252260
},
261+
262+
...(PRODUCTION_MODE ? {
263+
minimizer: [
264+
new TerserPlugin({
265+
terserOptions: {
266+
safari10: true,
267+
},
268+
}),
269+
],
270+
} : null),
253271
},
254272

255273
output: {
@@ -265,18 +283,3 @@ module.exports = {
265283

266284
resolve: browserConfig.resolve,
267285
};
268-
269-
if (String(process.env.WATCH_MODE) === '1') {
270-
Object.assign(module.exports, require('./webpack/watchConfig'));
271-
}
272-
273-
if (PRODUCTION_MODE) {
274-
module.exports.optimization.minimizer = [
275-
new TerserPlugin({
276-
sourceMap: true,
277-
terserOptions: {
278-
safari10: true,
279-
},
280-
}),
281-
];
282-
}

0 commit comments

Comments
 (0)