Skip to content

Commit 0627556

Browse files
chore: warn if webpack fails to create the fixtures (#383)
It's quite possible for webpack's cache to get messed up and then it can silently fail to build.
1 parent 8b539ba commit 0627556

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

packages/shared/tooling/webpack-compile.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import { spawnSync } from "child_process";
2+
import { rmSync, existsSync } from "fs";
3+
import path from "path";
4+
5+
const __dirname = new URL(".", import.meta.url).pathname;
6+
7+
const FIXTURES_DIR = path.join(__dirname, "../../../__fixtures__/dist");
28

39
export const compileForTests = () => {
10+
// It's necessary to manually remove the previous build artifacts so we can
11+
// check that the build is successful. This should not be necessary, but
12+
// webpack can fail silently.
13+
rmSync(FIXTURES_DIR, { recursive: true, force: true });
14+
415
// It's necessary spawnSync the webpack process to ensure that the build is
516
// complete before the tests start
617
const result = spawnSync(
@@ -12,6 +23,14 @@ export const compileForTests = () => {
1223
},
1324
);
1425

26+
if (!existsSync(FIXTURES_DIR)) {
27+
console.log(result.stdout);
28+
console.error(result.stderr);
29+
console.error(
30+
`Webpack build failed. The dist folder, ${FIXTURES_DIR}, was not created.`,
31+
);
32+
}
33+
1534
// Only log if there is an error
1635
if (result.status) {
1736
console.log(result.stdout);

0 commit comments

Comments
 (0)