1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00
denoland-deno/tools/bench/rebootstrap.js
Aaron O'Mullan 871dbb9f30 tools(bench): rebootstrap (#12281)
Enable deno devs to bench/profile/test JS code changes without doing a full --release rebuild.

Incremental release builds take ~4mn on M1s, often more on other machines ...
2021-10-04 11:55:06 -04:00

25 lines
896 B
JavaScript

import { dirname, fromFileUrl, join } from "https://deno.land/std/path/mod.ts";
import { expandGlobSync } from "https://deno.land/std/fs/mod.ts";
const ROOT_DIR = join(dirname(fromFileUrl(import.meta.url)), "..", "..");
export function rebootstrap(exts) {
[
"core/00_primordials.js",
...exts.map((e) => `ext/${e}/*.js`),
]
.map((pattern) => join(ROOT_DIR, pattern))
.map((pattern) => [...expandGlobSync(pattern)])
.flat()
.map((entry) => entry.path)
.forEach((file) => {
Deno.core.evalContext(Deno.readTextFileSync(file), file);
});
const bootstrap = globalThis.__bootstrap;
delete globalThis.__bootstrap;
// Patch dispatchEvent so we don't crash when MainWorker exits via:
// `window.dispatchEvent(new Event('unload'))`
// which fails since symbols are mangled during rebootstrap
globalThis.dispatchEvent = () => {};
return bootstrap;
}