30 lines
882 B
JavaScript
30 lines
882 B
JavaScript
#!/usr/bin/env node
|
|
const { spawnSync } = require("child_process");
|
|
const path = require("path");
|
|
const { getBuildProfile } = require("./build-resource-profile.cjs");
|
|
|
|
const profile = getBuildProfile();
|
|
const memHuman = `${profile.memMB}MB`;
|
|
const totalHuman = `${Math.round(profile.totalBytes / 1024 / 1024)}MB`;
|
|
console.log(
|
|
`[navsphere] build: heap=${profile.heapMB}MB parallelism=${profile.parallelism} cpus=${profile.cpus} mem≈${totalHuman} (${memHuman} effective)`
|
|
);
|
|
|
|
const nextBin = path.join(__dirname, "..", "node_modules", "next", "dist", "bin", "next");
|
|
const env = {
|
|
...process.env,
|
|
NAVSPHERE_WEBPACK_PARALLELISM: String(profile.parallelism),
|
|
};
|
|
|
|
const r = spawnSync(
|
|
process.execPath,
|
|
[`--max-old-space-size=${profile.heapMB}`, nextBin, "build"],
|
|
{
|
|
stdio: "inherit",
|
|
env,
|
|
cwd: path.join(__dirname, ".."),
|
|
}
|
|
);
|
|
|
|
process.exit(r.status ?? 1);
|