diff options
Diffstat (limited to 'src/js/builtins/codegen/index.ts')
-rw-r--r-- | src/js/builtins/codegen/index.ts | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/js/builtins/codegen/index.ts b/src/js/builtins/codegen/index.ts index a5d3c2dc8..5fbc15279 100644 --- a/src/js/builtins/codegen/index.ts +++ b/src/js/builtins/codegen/index.ts @@ -3,15 +3,23 @@ import path from "path"; import { sliceSourceCode } from "./builtin-parser"; import { applyGlobalReplacements, enums, globalsToPrefix } from "./replacements"; import { cap, fmtCPPString, low } from "./helpers"; -import { spawn, spawnSync } from "bun"; +import { spawn } from "bun"; async function createStaticHashtables() { const STATIC_HASH_TABLES = ["src/bun.js/bindings/Process.cpp"]; console.time("Creating static hash tables..."); - const create_hash_table = path.join( - import.meta.dir, - "../../../../bun-webkit/Source/JavaScriptCore/create_hash_table", - ); + const create_hash_table = [ + "src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table", + "bun-webkit/Source/JavaScriptCore/create_hash_table", + ] + .map(x => path.join(import.meta.dir, "../../../../" + x)) + .find(x => existsSync(x)); + if (!create_hash_table) { + console.warn( + "Could not find create_hash_table executable. Run `bun i` or clone webkit to build static hash tables", + ); + return; + } for (let cpp of STATIC_HASH_TABLES) { cpp = path.join(import.meta.dir, "../../../../", cpp); const { stdout, exited } = spawn({ @@ -49,6 +57,7 @@ const define = { "process.env.NODE_ENV": "development", "process.platform": process.platform, "process.arch": process.arch, + "$lazy": "___BUN_LAZY___", }; for (const name in enums) { @@ -226,7 +235,8 @@ $$capture_start$$(${fn.async ? "async " : ""}${ const finalReplacement = (fn.directives.sloppy ? captured : captured.replace(/function\s*\(.*?\)\s*{/, '$&"use strict";')) .replace(/^\((async )?function\(/, "($1function (") - .replace(/__intrinsic__/g, "@") + "\n"; + .replace(/__intrinsic__/g, "@") + .replace(/___BUN_LAZY___/g, "globalThis[globalThis.Symbol.for('Bun.lazy')]") + "\n"; bundledFunctions.push({ name: fn.name, |