aboutsummaryrefslogtreecommitdiff
path: root/src/js/_codegen/build-functions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/_codegen/build-functions.ts')
-rw-r--r--src/js/_codegen/build-functions.ts26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/js/_codegen/build-functions.ts b/src/js/_codegen/build-functions.ts
index 761682d44..fcce0263a 100644
--- a/src/js/_codegen/build-functions.ts
+++ b/src/js/_codegen/build-functions.ts
@@ -1,7 +1,7 @@
-import { existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from "fs";
+import { existsSync, mkdirSync, readdirSync, rmSync } from "fs";
import path from "path";
import { sliceSourceCode } from "./builtin-parser";
-import { applyGlobalReplacements, enums, globalsToPrefix } from "./replacements";
+import { applyGlobalReplacements, define } from "./replacements";
import { cap, fmtCPPString, low } from "./helpers";
import { spawn } from "bun";
@@ -48,24 +48,6 @@ const TMP_DIR = path.join(SRC_DIR, "../out/tmp/builtins");
if (existsSync(TMP_DIR)) rmSync(TMP_DIR, { recursive: true });
mkdirSync(TMP_DIR, { recursive: true });
-const define = {
- "process.env.NODE_ENV": "production",
- "IS_BUN_DEVELOPMENT": "false",
-};
-
-for (const name in enums) {
- const value = enums[name];
- if (typeof value !== "object") throw new Error("Invalid enum object " + name + " defined in " + import.meta.file);
- if (typeof value === null) throw new Error("Invalid enum object " + name + " defined in " + import.meta.file);
- const keys = Array.isArray(value) ? value : Object.keys(value).filter(k => !k.match(/^[0-9]+$/));
- define[`__intrinsic__${name}IdToLabel`] = "[" + keys.map(k => `"${k}"`).join(", ") + "]";
- define[`__intrinsic__${name}LabelToId`] = "{" + keys.map(k => `"${k}": ${keys.indexOf(k)}`).join(", ") + "}";
-}
-
-for (const name of globalsToPrefix) {
- define[name] = "__intrinsic__" + name;
-}
-
interface ParsedBuiltin {
name: string;
params: string[];
@@ -218,7 +200,7 @@ $$capture_start$$(${fn.async ? "async " : ""}${
const build = await Bun.build({
entrypoints: [tmpFile],
define,
- minify: { syntax: true, whitespace: true },
+ minify: { syntax: true, whitespace: false },
});
if (!build.success) {
throw new AggregateError(build.logs, "Failed bundling builtin function " + fn.name + " from " + basename + ".ts");
@@ -231,7 +213,7 @@ $$capture_start$$(${fn.async ? "async " : ""}${
const finalReplacement =
(fn.directives.sloppy ? captured : captured.replace(/function\s*\(.*?\)\s*{/, '$&"use strict";'))
.replace(/^\((async )?function\(/, "($1function (")
- .replace(/__intrinsic__lazy\(/g, "globalThis[globalThis.Symbol.for('Bun.lazy')](")
+ // .replace(/__intrinsic__lazy\(/g, "globalThis[globalThis.Symbol.for('Bun.lazy')](")
.replace(/__intrinsic__/g, "@") + "\n";
bundledFunctions.push({