diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-10-01 00:42:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 00:42:24 +0200 |
commit | b3ceafaa5dfee4127dff155cf6f4cc210f22ab59 (patch) | |
tree | a6c16ed129f70553046030d8ae3c253083187416 /tools/bench/rebootstrap.js | |
parent | 6bf5c850e6b4f6163721bd673b191bda0e0dc0a6 (diff) |
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 ...
Diffstat (limited to 'tools/bench/rebootstrap.js')
-rw-r--r-- | tools/bench/rebootstrap.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/bench/rebootstrap.js b/tools/bench/rebootstrap.js new file mode 100644 index 000000000..b85276ef3 --- /dev/null +++ b/tools/bench/rebootstrap.js @@ -0,0 +1,25 @@ +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; +} |