Skip to content

Commit bb6cc08

Browse files
committed
ref: Add child run to test webpack build
1 parent 1d12783 commit bb6cc08

File tree

3 files changed

+47
-11
lines changed

3 files changed

+47
-11
lines changed

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"test:jest": "jest",
6161
"test:watch": "jest --watch",
6262
"test:express": "node test/manual/express-scope-separation/start.js",
63-
"test:webpack": "cd test/manual/webpack-domain/ && yarn && yarn webpack && node dist/bundle.js",
63+
"test:webpack": "cd test/manual/webpack-domain/ && yarn && node npm-build.js",
6464
"version": "node ../../scripts/versionbump.js src/version.ts"
6565
},
6666
"jest": {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const { execSync } = require('child_process');
4+
5+
webpack(
6+
{
7+
entry: './index.js',
8+
output: {
9+
path: path.resolve(__dirname, 'dist'),
10+
filename: 'bundle.js',
11+
},
12+
target: 'node',
13+
mode: 'development',
14+
},
15+
(err, stats) => {
16+
if (err) {
17+
console.error(err.stack || err);
18+
if (err.details) {
19+
console.error(err.details);
20+
}
21+
return;
22+
}
23+
24+
const info = stats.toJson();
25+
26+
if (stats.hasErrors()) {
27+
console.error(info.errors);
28+
process.exit(1);
29+
}
30+
31+
if (stats.hasWarnings()) {
32+
console.warn(info.warnings);
33+
process.exit(1);
34+
}
35+
36+
runTests();
37+
},
38+
);
39+
40+
function runTests() {
41+
try {
42+
execSync(`node ${path.resolve(__dirname, 'dist', 'bundle.js')}`);
43+
} catch (_) {
44+
process.exit(1);
45+
}
46+
}

packages/node/test/manual/webpack-domain/webpack.config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)