diff options
author | 2023-07-12 15:21:55 -0700 | |
---|---|---|
committer | 2023-07-12 15:21:55 -0700 | |
commit | ae0a724981dd70f457d83f5f134e10dfbc7f72c5 (patch) | |
tree | fc094d1176c60a3378dab270264be3352d11ea87 /src/js/builtins/codegen/index.ts | |
parent | 0631f878667d9a5cab80d7c1167eac7cbc1c93c6 (diff) | |
download | bun-ae0a724981dd70f457d83f5f134e10dfbc7f72c5.tar.gz bun-ae0a724981dd70f457d83f5f134e10dfbc7f72c5.tar.zst bun-ae0a724981dd70f457d83f5f134e10dfbc7f72c5.zip |
Improve our internal typedefs (#3608)
* types
* some more
* yeah
* i think that fixes it
* oop
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, |