feat: update for Deno 2 (#2655)
Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
co-authored by
Luca Casonato
parent
b5389f69a3
commit
de8f1b0c59
@@ -40,6 +40,8 @@ Deno.test({
|
||||
|
||||
expect(logs).toEqual(["A", "B", "C"]);
|
||||
},
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
@@ -64,6 +66,8 @@ Deno.test({
|
||||
);
|
||||
expect(css).toContain('body { background: url("/foo.jpg?__frsh_c=');
|
||||
},
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
@@ -87,4 +91,6 @@ Deno.test({
|
||||
);
|
||||
expect(code).toContain('"remote-island"');
|
||||
},
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
+6
-15
@@ -131,20 +131,6 @@ export async function bundleJs(
|
||||
}
|
||||
|
||||
if (!options.dev) {
|
||||
// deno-lint-ignore no-deprecated-deno-api
|
||||
const children = Object.values(Deno.resources())
|
||||
.filter((name) => name === "child").length;
|
||||
await esbuild!.stop();
|
||||
// To work around a bug in ESBuild, where it doesn't wait for the child
|
||||
// process to shut down before exiting, we manually wait for the process to
|
||||
// exit before continuing.
|
||||
while (
|
||||
// deno-lint-ignore no-deprecated-deno-api
|
||||
Object.values(Deno.resources())
|
||||
.filter((name) => name === "child").length >= children
|
||||
) {
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
}
|
||||
esbuild = null;
|
||||
}
|
||||
|
||||
@@ -155,12 +141,17 @@ export async function bundleJs(
|
||||
};
|
||||
}
|
||||
|
||||
let initialized = false;
|
||||
|
||||
export async function startEsbuild() {
|
||||
esbuild = Deno.env.get("FRESH_ESBUILD_LOADER") === "portable"
|
||||
? await import("esbuild-wasm")
|
||||
: await import("esbuild");
|
||||
|
||||
await esbuild.initialize({});
|
||||
if (!initialized) {
|
||||
await esbuild.initialize({});
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
function buildIdPlugin(buildId: string): EsbuildPlugin {
|
||||
|
||||
@@ -105,10 +105,11 @@ export async function updateCheck(
|
||||
checkFile.latest_version = await getLatestVersion();
|
||||
checkFile.last_checked = new Date().toISOString();
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
// Update check is optional and shouldn't abort the program.
|
||||
// deno-lint-ignore no-console
|
||||
console.error(
|
||||
colors.red(` Update check failed: `) + err.message,
|
||||
colors.red(` Update check failed: `) + message,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user