Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions web/scripts/build-web.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ function doHelp() {
}

async function doWatch() {
const { promise, resolve, reject } = Promise.withResolvers();

logger.info(`🤖 Watching entry points:\n\t${Object.keys(EntryPoint).join("\n\t")}`);

const entryPoints = Object.values(EntryPoint);
Expand Down Expand Up @@ -182,23 +184,31 @@ async function doWatch() {
logger.info(`🔓 ${httpURL.href}`);
logger.info(`🔒 ${httpsURL.href}`);

return /** @type {Promise<void>} */ (
new Promise((resolve) => {
process.on("SIGINT", () => {
resolve();
});
})
);
let disposing = false;

const delegateShutdown = () => {
logger.flush();
console.log("");

// We prevent multiple attempts to dispose the context
// because ESBuild will repeatedly restart its internal clean-up logic.
// However, sending a second SIGINT will still exit the process immediately.
if (disposing) return;

disposing = true;

return buildContext.dispose().then(resolve).catch(reject);
};

process.on("SIGINT", delegateShutdown);

return promise;
}

async function doBuild() {
logger.info(`🚀 Building entry points:`);

const entryPoints = Object.entries(EntryPoint).map(([entrypointID, target]) => {
logger.info(entrypointID);
logger.info(`🤖 Watching entry points:\n\t${Object.keys(EntryPoint).join("\n\t")}`);

return target;
});
const entryPoints = Object.values(EntryPoint);

const buildOptions = createESBuildOptions({
entryPoints,
Expand Down
Loading