@remix-run/server-runtime
Version:
Server runtime for Remix
43 lines (39 loc) • 1.17 kB
JavaScript
/**
* @remix-run/server-runtime v1.19.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
async function broadcastDevReady(build, origin) {
origin ?? (origin = process.env.REMIX_DEV_HTTP_ORIGIN);
if (!origin) throw Error("Dev server origin not set");
let url = new URL(origin);
url.pathname = "ping";
let response = await fetch(url.href, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
buildHash: build.assets.version
})
}).catch(error => {
console.error(`Could not reach Remix dev server at ${url}`);
throw error;
});
if (!response.ok) {
console.error(`Could not reach Remix dev server at ${url} (${response.status})`);
throw Error(await response.text());
}
}
function logDevReady(build) {
console.log(`[REMIX DEV] ${build.assets.version} ready`);
}
exports.broadcastDevReady = broadcastDevReady;
exports.logDevReady = logDevReady;