oven-sh/bun · error · Error
This script is not meant to be run directly
Error message
This script is not meant to be run directly
What it means
Entry guard in bundle-functions.ts: the module detected that it is running as the main script (import.meta.main is true). This file is a library of codegen helpers meant to be imported by the build scripts; running it directly does nothing useful because its generation entry points require a build configuration to be set up first.
Solutions
- Invoke the codegen through the intended build script (e.g. the codegen entry point that imports this module) rather than `bun src/codegen/bundle-functions.ts`
- If direct execution should be supported, replace the guard with a CLI entry point that sets up the required configuration and drives generation
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/codegen/bundle-functions.ts:58 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/d48235444a5a4bf2.
Report an issue: GitHub.
Appendix: source
Thrown at src/codegen/bundle-functions.ts:58
// The output is intended to be similar to what WebCore does, but they use a
// python script, and they write all the `@` syntax by hand. When generating,
// we concatenate all the sources into one big string, which then creates a
// single JSC::SourceProvider. Passing start/end positions to each function's
// JSC::SourceCode. JSC does this, but WebCore does not seem to as of writing.
import assert from "assert";
import { readdirSync, rmSync } from "fs";
import path from "path";
import { sliceSourceCode } from "./builtin-parser";
import { createAssertClientJS, createLogClientJS } from "./client-js";
import { getJS2NativeDTS } from "./generate-js2native";
import { cap, checkAscii, low, writeIfNotChanged } from "./helpers";
import { applyGlobalReplacements, define } from "./replacements";
const PARALLEL = false;
const KEEP_TMP = true;
if (import.meta.main) {
throw new Error("This script is not meant to be run directly");
}
const CMAKE_BUILD_ROOT = globalThis.CMAKE_BUILD_ROOT;
if (!CMAKE_BUILD_ROOT) {
throw new Error("CMAKE_BUILD_ROOT is not defined");
}
const SRC_DIR = path.join(import.meta.dir, "../js/builtins");
const CODEGEN_DIR = path.join(CMAKE_BUILD_ROOT, "./codegen");
const TMP_DIR = path.join(CMAKE_BUILD_ROOT, "./tmp_functions");
interface ParsedBuiltin {
name: string;
params: string[];
directives: Record<string, any>;
source: string;
async: boolean;
enums: string[];View on GitHub (pinned to 8c5296ac45)