diff --git a/build.zig b/build.zig index 9f664a5ec7..d81052af40 100644 --- a/build.zig +++ b/build.zig @@ -56,10 +56,10 @@ const BunBuildOptions = struct { /// - src/bun.js/api/FFI.h /// /// A similar technique is used in C++ code for JavaScript builtins - force_embed_code: bool = false, + codegen_embed: bool = false, /// `./build/codegen` or equivalent - generated_code_dir: []const u8, + codegen_path: []const u8, no_llvm: bool, cached_options_module: ?*Module = null, @@ -71,7 +71,7 @@ const BunBuildOptions = struct { } pub fn shouldEmbedCode(opts: *const BunBuildOptions) bool { - return opts.optimize != .Debug or opts.force_embed_code; + return opts.optimize != .Debug or opts.codegen_embed; } pub fn buildOptionsModule(this: *BunBuildOptions, b: *Build) *Module { @@ -83,10 +83,10 @@ const BunBuildOptions = struct { opts.addOption([]const u8, "base_path", b.pathFromRoot(".")); opts.addOption([]const u8, "codegen_path", std.fs.path.resolve(b.graph.arena, &.{ b.build_root.path.?, - this.generated_code_dir, + this.codegen_path, }) catch @panic("OOM")); - opts.addOption(bool, "embed_code", this.shouldEmbedCode()); + opts.addOption(bool, "codegen_embed", this.shouldEmbedCode()); opts.addOption(u32, "canary_revision", this.canary_revision orelse 0); opts.addOption(bool, "is_canary", this.canary_revision != null); opts.addOption(Version, "version", this.version); @@ -195,12 +195,13 @@ pub fn build(b: *Build) !void { const target = b.resolveTargetQuery(target_query); - const generated_code_dir = b.pathFromRoot( - b.option([]const u8, "generated-code", "Set the generated code directory") orelse + const codegen_path = b.pathFromRoot( + b.option([]const u8, "codegen_path", "Set the generated code directory") orelse "build/debug/codegen", ); + const codegen_embed = b.option(bool, "codegen_embed", "If codegen files should be embedded in the binary") orelse false; + const bun_version = b.option([]const u8, "version", "Value of `Bun.version`") orelse "0.0.0"; - const force_embed_js_code = b.option(bool, "force_embed_js_code", "Always embed JavaScript builtins") orelse false; b.reference_trace = ref_trace: { const trace = b.option(u32, "reference-trace", "Set the reference trace") orelse 16; @@ -218,8 +219,8 @@ pub fn build(b: *Build) !void { .os = os, .arch = arch, - .generated_code_dir = generated_code_dir, - .force_embed_code = force_embed_js_code, + .codegen_path = codegen_path, + .codegen_embed = codegen_embed, .no_llvm = no_llvm, .version = try Version.parse(bun_version), @@ -351,7 +352,7 @@ pub inline fn addMultiCheck( .tracy_callstack_depth = root_build_options.tracy_callstack_depth, .version = root_build_options.version, .reported_nodejs_version = root_build_options.reported_nodejs_version, - .generated_code_dir = root_build_options.generated_code_dir, + .codegen_path = root_build_options.codegen_path, .no_llvm = root_build_options.no_llvm, }; @@ -475,13 +476,44 @@ fn addInternalPackages(b: *Build, obj: *Compile, opts: *BunBuildOptions) void { .{ .file = "ZigGeneratedClasses.zig", .import = "ZigGeneratedClasses" }, .{ .file = "ResolvedSourceTag.zig", .import = "ResolvedSourceTag" }, .{ .file = "ErrorCode.zig", .import = "ErrorCode" }, + .{ .file = "runtime.out.js" }, .{ .file = "bake.client.js", .import = "bake-codegen/bake.client.js", .enable = opts.shouldEmbedCode() }, .{ .file = "bake.server.js", .import = "bake-codegen/bake.server.js", .enable = opts.shouldEmbedCode() }, + .{ .file = "bun-error/index.js", .enable = opts.shouldEmbedCode() }, + .{ .file = "bun-error/bun-error.css", .enable = opts.shouldEmbedCode() }, + .{ .file = "fallback-decoder.js", .enable = opts.shouldEmbedCode() }, + .{ .file = "node-fallbacks/assert.js" }, + .{ .file = "node-fallbacks/buffer.js" }, + .{ .file = "node-fallbacks/console.js" }, + .{ .file = "node-fallbacks/constants.js" }, + .{ .file = "node-fallbacks/crypto.js" }, + .{ .file = "node-fallbacks/domain.js" }, + .{ .file = "node-fallbacks/events.js" }, + .{ .file = "node-fallbacks/http.js" }, + .{ .file = "node-fallbacks/https.js" }, + .{ .file = "node-fallbacks/net.js" }, + .{ .file = "node-fallbacks/os.js" }, + .{ .file = "node-fallbacks/path.js" }, + .{ .file = "node-fallbacks/process.js" }, + .{ .file = "node-fallbacks/punycode.js" }, + .{ .file = "node-fallbacks/querystring.js" }, + .{ .file = "node-fallbacks/stream.js" }, + .{ .file = "node-fallbacks/string_decoder.js" }, + .{ .file = "node-fallbacks/sys.js" }, + .{ .file = "node-fallbacks/timers.js" }, + .{ .file = "node-fallbacks/tty.js" }, + .{ .file = "node-fallbacks/url.js" }, + .{ .file = "node-fallbacks/util.js" }, + .{ .file = "node-fallbacks/zlib.js" }, }) |entry| { if (!@hasField(@TypeOf(entry), "enable") or entry.enable) { - const path = b.pathJoin(&.{ opts.generated_code_dir, entry.file }); + const path = b.pathJoin(&.{ opts.codegen_path, entry.file }); validateGeneratedPath(path); - obj.root_module.addAnonymousImport(entry.import, .{ + const import_path = if (@hasField(@TypeOf(entry), "import")) + entry.import + else + entry.file; + obj.root_module.addAnonymousImport(import_path, .{ .root_source_file = .{ .cwd_relative = path }, }); } diff --git a/cmake/targets/BuildBun.cmake b/cmake/targets/BuildBun.cmake index 9c24f0cb6b..38c8003c5d 100644 --- a/cmake/targets/BuildBun.cmake +++ b/cmake/targets/BuildBun.cmake @@ -21,10 +21,16 @@ else() set(buns ${bun}) endif() -# Some commands use this path, and some do not. -# In the future, change those commands so that generated files are written to this path. optionx(CODEGEN_PATH FILEPATH "Path to the codegen directory" DEFAULT ${BUILD_PATH}/codegen) +if(RELEASE OR CI) + set(DEFAULT_CODEGEN_EMBED ON) +else() + set(DEFAULT_CODEGEN_EMBED OFF) +endif() + +optionx(CODEGEN_EMBED BOOL "If codegen files should be embedded in the binary" DEFAULT ${DEFAULT_CODEGEN_EMBED}) + if((NOT DEFINED CONFIGURE_DEPENDS AND NOT CI) OR CONFIGURE_DEPENDS) set(CONFIGURE_DEPENDS "CONFIGURE_DEPENDS") else() @@ -33,39 +39,6 @@ endif() # --- Codegen --- -set(BUN_ZIG_IDENTIFIER_SOURCE ${CWD}/src/js_lexer) -set(BUN_ZIG_IDENTIFIER_SCRIPT ${BUN_ZIG_IDENTIFIER_SOURCE}/identifier_data.zig) - -file(GLOB BUN_ZIG_IDENTIFIER_SOURCES ${CONFIGURE_DEPENDS} - ${BUN_ZIG_IDENTIFIER_SCRIPT} - ${BUN_ZIG_IDENTIFIER_SOURCE}/*.zig -) - -set(BUN_ZIG_IDENTIFIER_OUTPUTS - ${BUN_ZIG_IDENTIFIER_SOURCE}/id_continue_bitset.blob - ${BUN_ZIG_IDENTIFIER_SOURCE}/id_continue_bitset.meta.blob - ${BUN_ZIG_IDENTIFIER_SOURCE}/id_start_bitset.blob - ${BUN_ZIG_IDENTIFIER_SOURCE}/id_start_bitset.meta.blob -) - -register_command( - TARGET - bun-identifier-data - COMMENT - "Generating src/js_lexer/*.blob" - COMMAND - ${ZIG_EXECUTABLE} - run - ${CMAKE_ZIG_FLAGS} - ${BUN_ZIG_IDENTIFIER_SCRIPT} - SOURCES - ${BUN_ZIG_IDENTIFIER_SOURCES} - TARGETS - clone-zig - OUTPUTS - ${BUN_ZIG_IDENTIFIER_OUTPUTS} -) - set(BUN_ERROR_SOURCE ${CWD}/packages/bun-error) file(GLOB BUN_ERROR_SOURCES ${CONFIGURE_DEPENDS} @@ -76,7 +49,7 @@ file(GLOB BUN_ERROR_SOURCES ${CONFIGURE_DEPENDS} ${BUN_ERROR_SOURCE}/img/* ) -set(BUN_ERROR_OUTPUT ${BUN_ERROR_SOURCE}/dist) +set(BUN_ERROR_OUTPUT ${CODEGEN_PATH}/bun-error) set(BUN_ERROR_OUTPUTS ${BUN_ERROR_OUTPUT}/index.js ${BUN_ERROR_OUTPUT}/bun-error.css @@ -114,13 +87,13 @@ register_command( ) set(BUN_FALLBACK_DECODER_SOURCE ${CWD}/src/fallback.ts) -set(BUN_FALLBACK_DECODER_OUTPUT ${CWD}/src/fallback.out.js) +set(BUN_FALLBACK_DECODER_OUTPUT ${CODEGEN_PATH}/fallback-decoder.js) register_command( TARGET bun-fallback-decoder COMMENT - "Building src/fallback.out.js" + "Building fallback-decoder.js" COMMAND ${ESBUILD_EXECUTABLE} ${ESBUILD_ARGS} ${BUN_FALLBACK_DECODER_SOURCE} @@ -137,7 +110,7 @@ register_command( ) set(BUN_RUNTIME_JS_SOURCE ${CWD}/src/runtime.bun.js) -set(BUN_RUNTIME_JS_OUTPUT ${CWD}/src/runtime.out.js) +set(BUN_RUNTIME_JS_OUTPUT ${CODEGEN_PATH}/runtime.out.js) register_command( TARGET @@ -167,7 +140,7 @@ file(GLOB BUN_NODE_FALLBACKS_SOURCES ${CONFIGURE_DEPENDS} ${BUN_NODE_FALLBACKS_SOURCE}/*.js ) -set(BUN_NODE_FALLBACKS_OUTPUT ${BUN_NODE_FALLBACKS_SOURCE}/out) +set(BUN_NODE_FALLBACKS_OUTPUT ${CODEGEN_PATH}/node-fallbacks) set(BUN_NODE_FALLBACKS_OUTPUTS) foreach(source ${BUN_NODE_FALLBACKS_SOURCES}) get_filename_component(filename ${source} NAME) @@ -187,7 +160,7 @@ register_command( TARGET bun-node-fallbacks COMMENT - "Building src/node-fallbacks/*.js" + "Building node-fallbacks/*.js" CWD ${BUN_NODE_FALLBACKS_SOURCE} COMMAND @@ -491,7 +464,6 @@ list(APPEND BUN_ZIG_SOURCES ) set(BUN_ZIG_GENERATED_SOURCES - ${BUN_ZIG_IDENTIFIER_OUTPUTS} ${BUN_ERROR_OUTPUTS} ${BUN_FALLBACK_DECODER_OUTPUT} ${BUN_RUNTIME_JS_OUTPUT} @@ -547,7 +519,8 @@ register_command( -Dsha=${REVISION} -Dreported_nodejs_version=${NODEJS_VERSION} -Dcanary=${CANARY_REVISION} - -Dgenerated-code=${CODEGEN_PATH} + -Dcodegen_path=${CODEGEN_PATH} + -Dcodegen_embed=$,true,false> ARTIFACTS ${BUN_ZIG_OUTPUT} TARGETS diff --git a/root.zig b/root.zig index 6255deec04..4778a56d1b 100644 --- a/root.zig +++ b/root.zig @@ -3,16 +3,6 @@ pub usingnamespace @import("./src/main.zig"); /// These functions are used throughout Bun's codebase. pub const bun = @import("./src/bun.zig"); -pub const content = struct { - pub const error_js_path = "packages/bun-error/dist/index.js"; - pub const error_js = @embedFile(error_js_path); - - pub const error_css_path = "packages/bun-error/dist/bun-error.css"; - pub const error_css_path_dev = "packages/bun-error/bun-error.css"; - - pub const error_css = @embedFile(error_css_path); -}; - pub const completions = struct { pub const bash = @embedFile("./completions/bun.bash"); pub const zsh = @embedFile("./completions/bun.zsh"); diff --git a/root_wasm.zig b/root_wasm.zig index f04ceb015c..7865cc0471 100644 --- a/root_wasm.zig +++ b/root_wasm.zig @@ -2,16 +2,6 @@ pub usingnamespace @import("src/main_wasm.zig"); pub const bun = @import("src/bun.zig"); -pub const content = struct { - pub const error_js_path = "packages/bun-error/dist/index.js"; - pub const error_js = @embedFile(error_js_path); - - pub const error_css_path = "packages/bun-error/dist/bun-error.css"; - pub const error_css_path_dev = "packages/bun-error/bun-error.css"; - - pub const error_css = @embedFile(error_css_path); -}; - pub const completions = struct {}; pub const is_bindgen = true; pub const JavaScriptCore = struct { diff --git a/src/bake/DevServer.zig b/src/bake/DevServer.zig index 7c432f832b..e73eb7bd06 100644 --- a/src/bake/DevServer.zig +++ b/src/bake/DevServer.zig @@ -383,7 +383,7 @@ fn onIncrementalVisualizer(_: *DevServer, _: *Request, resp: *Response) void { } fn onIncrementalVisualizerCorked(resp: *Response) void { - const code = if (Environment.embed_code) + const code = if (Environment.codegen_embed) @embedFile("incremental_visualizer.html") else bun.runtimeEmbedFile(.src_eager, "bake/incremental_visualizer.html"); diff --git a/src/bake/bake.zig b/src/bake/bake.zig index b845ea5b83..0ab09589e4 100644 --- a/src/bake/bake.zig +++ b/src/bake/bake.zig @@ -68,7 +68,7 @@ pub const Framework = struct { "bun-framework-rsc/client.tsx", "bun-framework-rsc/server.tsx", "bun-framework-rsc/ssr.tsx", - }, if (Environment.embed_code) &.{ + }, if (Environment.codegen_embed) &.{ .{ .code = @embedFile("./bun-framework-rsc/client.tsx") }, .{ .code = @embedFile("./bun-framework-rsc/server.tsx") }, .{ .code = @embedFile("./bun-framework-rsc/ssr.tsx") }, @@ -320,7 +320,7 @@ pub fn wipDevServer(options: DevServer.Options) noreturn { } pub fn getHmrRuntime(mode: Side) []const u8 { - return if (Environment.embed_code) + return if (Environment.codegen_embed) switch (mode) { .client => @embedFile("bake-codegen/bake.client.js"), .server => @embedFile("bake-codegen/bake.server.js"), diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index 16ffd94075..4e83add580 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -1517,7 +1517,7 @@ pub const FFI = struct { }; pub fn ffiHeader() string { - return if (Environment.embed_code) + return if (Environment.codegen_embed) @embedFile("./FFI.h") else bun.runtimeEmbedFile(.src, "bun.js/api/FFI.h"); diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 4e060ac290..dad8da4bee 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -2293,7 +2293,7 @@ pub const VirtualMachine = struct { ret.result = null; ret.path = specifier; return; - } else if (strings.hasPrefixComptime(specifier, "/bun-vfs/node_modules/")) { + } else if (strings.hasPrefixComptime(specifier, NodeFallbackModules.import_path)) { ret.result = null; ret.path = specifier; return; diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index c8b876c811..f597d2dbd7 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -436,7 +436,7 @@ pub const RuntimeTranspilerStore = struct { } // this should be a cheap lookup because 24 bytes == 8 * 3 so it's read 3 machine words - const is_node_override = strings.hasPrefixComptime(specifier, "/bun-vfs/node_modules/"); + const is_node_override = strings.hasPrefixComptime(specifier, NodeFallbackModules.import_path); const macro_remappings = if (vm.macro_mode or !vm.has_any_macro_remappings or is_node_override) MacroRemap{} @@ -1587,7 +1587,7 @@ pub const ModuleLoader = struct { } // this should be a cheap lookup because 24 bytes == 8 * 3 so it's read 3 machine words - const is_node_override = strings.hasPrefixComptime(specifier, "/bun-vfs/node_modules/"); + const is_node_override = strings.hasPrefixComptime(specifier, NodeFallbackModules.import_path); const macro_remappings = if (jsc_vm.macro_mode or !jsc_vm.has_any_macro_remappings or is_node_override) MacroRemap{} diff --git a/src/bun.zig b/src/bun.zig index 243ad41673..efbdce6653 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -3296,26 +3296,36 @@ pub fn getUserName(output_buffer: []u8) ?[]const u8 { return output_buffer[0..size]; } -pub fn runtimeEmbedFile( - comptime root: enum { codegen, src, src_eager }, - comptime sub_path: []const u8, -) []const u8 { - comptime assert(Environment.isDebug); - comptime assert(!Environment.embed_code); - - const abs_path = comptime path: { +pub inline fn resolveSourcePath( + comptime root: enum { codegen, src }, + comptime sub_path: string, +) string { + return comptime path: { var buf: bun.PathBuffer = undefined; var fba = std.heap.FixedBufferAllocator.init(&buf); const resolved = (std.fs.path.resolve(fba.allocator(), &.{ switch (root) { .codegen => Environment.codegen_path, - .src, .src_eager => Environment.base_path ++ "/src", + .src => Environment.base_path ++ "/src", }, sub_path, }) catch @compileError(unreachable))[0..].*; break :path &resolved; }; +} + +pub fn runtimeEmbedFile( + comptime root: enum { codegen, src, src_eager }, + comptime sub_path: []const u8, +) []const u8 { + comptime assert(Environment.isDebug); + comptime assert(!Environment.codegen_embed); + + const abs_path = switch (root) { + .codegen => resolveSourcePath(.codegen, sub_path), + .src, .src_eager => resolveSourcePath(.src, sub_path), + }; const static = struct { var storage: []const u8 = undefined; @@ -3328,7 +3338,7 @@ pub fn runtimeEmbedFile( \\ \\To improve iteration speed, some files are not embedded but \\loaded at runtime, at the cost of making the binary non-portable. - \\To fix this, pass -DFORCE_EMBED_CODE=1 to CMake + \\To fix this, pass -DCODEGEN_EMBED=ON to CMake , .{ abs_path, e }); }; } diff --git a/src/env.zig b/src/env.zig index 2f6f528abc..3ced38ab31 100644 --- a/src/env.zig +++ b/src/env.zig @@ -41,10 +41,8 @@ pub const dump_source = isDebug and !isTest; pub const base_path = build_options.base_path; pub const enable_logs = build_options.enable_logs or isDebug; -/// See -Dforce_embed_code -pub const embed_code = build_options.embed_code; - pub const codegen_path = build_options.codegen_path; +pub const codegen_embed = build_options.codegen_embed; pub const version: std.SemanticVersion = build_options.version; pub const version_string = std.fmt.comptimePrint("{d}.{d}.{d}", .{ version.major, version.minor, version.patch }); diff --git a/src/js_lexer/identifier_cache.zig b/src/js_lexer/identifier_cache.zig index 21511846fe..de1ea0e771 100644 --- a/src/js_lexer/identifier_cache.zig +++ b/src/js_lexer/identifier_cache.zig @@ -1,5 +1,6 @@ const std = @import("std"); const bun = @import("root").bun; +const identifier_data = @import("./identifier_data.zig"); pub const CachedBitset = extern struct { range: [2]i32, @@ -15,16 +16,7 @@ pub fn setMasks(masks: [*:0]const u8, comptime MaskType: type, masky: MaskType) masky.masks = @as(masks, @bitCast(FieldInfo.type)); } -pub const id_start_meta = CachedBitset.fromFile("id_start_bitset.meta.blob"); -pub const id_continue_meta = CachedBitset.fromFile("id_continue_bitset.meta.blob"); -pub const id_start_masks = @embedFile("id_start_bitset.blob"); -pub const id_continue_masks = @embedFile("id_continue_bitset.blob"); - -pub const IDStartType = bun.bit_set.ArrayBitSet(usize, id_start_meta.len); -pub const IDContinueType = bun.bit_set.ArrayBitSet(usize, id_continue_meta.len); -pub const id_start = IDStartType{ - .masks = @as(std.meta.fieldInfo(IDStartType, .masks).type, @bitCast(@as(*const [id_start_masks.len]u8, @ptrCast(id_start_masks)).*)), -}; -pub const id_continue = IDContinueType{ - .masks = @as(std.meta.fieldInfo(IDContinueType, .masks).type, @bitCast(@as(*const [id_continue_masks.len]u8, @ptrCast(id_continue_masks)).*)), -}; +pub const id_start_meta = identifier_data.id_start_cached; +pub const id_continue_meta = identifier_data.id_continue_cached; +pub const id_start = identifier_data.id_start; +pub const id_continue = identifier_data.id_continue; diff --git a/src/js_lexer/identifier_data.zig b/src/js_lexer/identifier_data.zig index b9ce7afa2d..d82751e620 100644 --- a/src/js_lexer/identifier_data.zig +++ b/src/js_lexer/identifier_data.zig @@ -60,7 +60,7 @@ const id_end_count = id_end_range[1] - id_end_range[0] + 1; pub const IDStartType = std.bit_set.StaticBitSet(id_start_count + 1); pub const IDContinueType = std.bit_set.StaticBitSet(id_end_count + 1); -const id_start: IDStartType = brk: { +pub const id_start: IDStartType = brk: { var bits: IDStartType = IDStartType.initEmpty(); var i: usize = 0; @@ -76,7 +76,7 @@ const id_start: IDStartType = brk: { break :brk bits; }; -const id_continue: IDContinueType = brk: { +pub const id_continue: IDContinueType = brk: { var bits: IDContinueType = IDContinueType.initEmpty(); var i: usize = 0; @@ -94,10 +94,10 @@ const id_continue: IDContinueType = brk: { const Cache = @import("./identifier_cache.zig"); -pub fn main() anyerror!void { - var id_start_cached = Cache.CachedBitset{ .range = id_start_range, .len = id_start_count + 1 }; - var id_continue_cached = Cache.CachedBitset{ .range = id_end_range, .len = id_end_count + 1 }; +pub const id_start_cached = Cache.CachedBitset{ .range = id_start_range, .len = id_start_count + 1 }; +pub const id_continue_cached = Cache.CachedBitset{ .range = id_end_range, .len = id_end_count + 1 }; +fn main() anyerror!void { const id_continue_data = std.mem.asBytes(&id_continue.masks); const id_start_data = std.mem.asBytes(&id_start.masks); diff --git a/src/node_fallbacks.zig b/src/node_fallbacks.zig index b2808744a0..89998d3a13 100644 --- a/src/node_fallbacks.zig +++ b/src/node_fallbacks.zig @@ -4,454 +4,78 @@ const PackageJSON = @import("./resolver/package_json.zig").PackageJSON; const logger = bun.logger; const Fs = @import("./fs.zig"); const bun = @import("root").bun; +const Environment = bun.Environment; -const assert_code: string = @embedFile("./node-fallbacks/out/assert.js"); -const buffer_code: string = @embedFile("./node-fallbacks/out/buffer.js"); -const console_code: string = @embedFile("./node-fallbacks/out/console.js"); -const constants_code: string = @embedFile("./node-fallbacks/out/constants.js"); -const crypto_code: string = @embedFile("./node-fallbacks/out/crypto.js"); -const domain_code: string = @embedFile("./node-fallbacks/out/domain.js"); -const events_code: string = @embedFile("./node-fallbacks/out/events.js"); -const http_code: string = @embedFile("./node-fallbacks/out/http.js"); -const https_code: string = @embedFile("./node-fallbacks/out/https.js"); -const net_code: string = @embedFile("./node-fallbacks/out/net.js"); -const os_code: string = @embedFile("./node-fallbacks/out/os.js"); -const path_code: string = @embedFile("./node-fallbacks/out/path.js"); -const process_code: string = @embedFile("./node-fallbacks/out/process.js"); -const punycode_code: string = @embedFile("./node-fallbacks/out/punycode.js"); -const querystring_code: string = @embedFile("./node-fallbacks/out/querystring.js"); -const stream_code: string = @embedFile("./node-fallbacks/out/stream.js"); -const string_decoder_code: string = @embedFile("./node-fallbacks/out/string_decoder.js"); -const sys_code: string = @embedFile("./node-fallbacks/out/sys.js"); -const timers_code: string = @embedFile("./node-fallbacks/out/timers.js"); -const tty_code: string = @embedFile("./node-fallbacks/out/tty.js"); -const url_code: string = @embedFile("./node-fallbacks/out/url.js"); -const util_code: string = @embedFile("./node-fallbacks/out/util.js"); -const zlib_code: string = @embedFile("./node-fallbacks/out/zlib.js"); +pub const import_path = "/bun-vfs$$/node_modules/"; -const assert_import_path = "/bun-vfs/node_modules/assert/index.js"; -const buffer_import_path = "/bun-vfs/node_modules/buffer/index.js"; -const console_import_path = "/bun-vfs/node_modules/console/index.js"; -const constants_import_path = "/bun-vfs/node_modules/constants/index.js"; -const crypto_import_path = "/bun-vfs/node_modules/crypto/index.js"; -const domain_import_path = "/bun-vfs/node_modules/domain/index.js"; -const events_import_path = "/bun-vfs/node_modules/events/index.js"; -const http_import_path = "/bun-vfs/node_modules/http/index.js"; -const https_import_path = "/bun-vfs/node_modules/https/index.js"; -const net_import_path = "/bun-vfs/node_modules/net/index.js"; -const os_import_path = "/bun-vfs/node_modules/os/index.js"; -const path_import_path = "/bun-vfs/node_modules/path/index.js"; -const process_import_path = "/bun-vfs/node_modules/process/index.js"; -const punycode_import_path = "/bun-vfs/node_modules/punycode/index.js"; -const querystring_import_path = "/bun-vfs/node_modules/querystring/index.js"; -const stream_import_path = "/bun-vfs/node_modules/stream/index.js"; -const string_decoder_import_path = "/bun-vfs/node_modules/string_decoder/index.js"; -const sys_import_path = "/bun-vfs/node_modules/sys/index.js"; -const timers_import_path = "/bun-vfs/node_modules/timers/index.js"; -const tty_import_path = "/bun-vfs/node_modules/tty/index.js"; -const url_import_path = "/bun-vfs/node_modules/url/index.js"; -const util_import_path = "/bun-vfs/node_modules/util/index.js"; -const zlib_import_path = "/bun-vfs/node_modules/zlib/index.js"; - -const assert_package_json = PackageJSON{ - .name = "assert", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("assert@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/assert/package.json", ""), - .side_effects = .false, -}; -const buffer_package_json = PackageJSON{ - .name = "buffer", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("buffer@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/buffer/package.json", ""), - .side_effects = .false, -}; -const console_package_json = PackageJSON{ - .name = "console", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("console@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/console/package.json", ""), - .side_effects = .false, -}; -const constants_package_json = PackageJSON{ - .name = "constants", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("constants@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/constants/package.json", ""), - .side_effects = .false, -}; -const crypto_package_json = PackageJSON{ - .name = "crypto", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("crypto@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/crypto/package.json", ""), - .side_effects = .false, -}; -const domain_package_json = PackageJSON{ - .name = "domain", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("domain@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/domain/package.json", ""), - .side_effects = .false, -}; -const events_package_json = PackageJSON{ - .name = "events", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("events@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/events/package.json", ""), - .side_effects = .false, -}; -const http_package_json = PackageJSON{ - .name = "http", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("http@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/http/package.json", ""), - .side_effects = .false, -}; -const https_package_json = PackageJSON{ - .name = "https", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("https@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/https/package.json", ""), - .side_effects = .false, -}; -const net_package_json = PackageJSON{ - .name = "net", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("net@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/net/package.json", ""), - .side_effects = .false, -}; -const os_package_json = PackageJSON{ - .name = "os", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("os@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/os/package.json", ""), - .side_effects = .false, -}; -const path_package_json = PackageJSON{ - .name = "path", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("path@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/path/package.json", ""), - .side_effects = .false, -}; -const process_package_json = PackageJSON{ - .name = "process", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("process@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/process/package.json", ""), - .side_effects = .false, -}; -const punycode_package_json = PackageJSON{ - .name = "punycode", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("punycode@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/punycode/package.json", ""), - .side_effects = .false, -}; -const querystring_package_json = PackageJSON{ - .name = "querystring", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("querystring@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/querystring/package.json", ""), - .side_effects = .false, -}; -const stream_package_json = PackageJSON{ - .name = "stream", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("stream@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/stream/package.json", ""), - .side_effects = .false, -}; -const string_decoder_package_json = PackageJSON{ - .name = "string_decoder", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = brk: { - @setEvalBranchQuota(9999); - break :brk @as(u32, @truncate(bun.hash("string_decoder@0.0.0-polyfill"))); - }, - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/string_decoder/package.json", ""), - .side_effects = .false, -}; -const sys_package_json = PackageJSON{ - .name = "sys", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("sys@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/sys/package.json", ""), - .side_effects = .false, -}; -const timers_package_json = PackageJSON{ - .name = "timers", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("timers@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/timers/package.json", ""), - .side_effects = .false, -}; -const tty_package_json = PackageJSON{ - .name = "tty", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("tty@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/tty/package.json", ""), - .side_effects = .false, -}; -const url_package_json = PackageJSON{ - .name = "url", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("url@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/url/package.json", ""), - .side_effects = .false, -}; -const util_package_json = PackageJSON{ - .name = "util", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("util@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/util/package.json", ""), - .side_effects = .false, -}; -const zlib_package_json = PackageJSON{ - .name = "zlib", - .version = "0.0.0-polyfill", - .module_type = .esm, - .hash = @as(u32, @truncate(bun.hash("zlib@0.0.0-polyfill"))), - .main_fields = undefined, - .browser_map = undefined, - .source = logger.Source.initPathString("/bun-vfs/node_modules/zlib/package.json", ""), - .side_effects = .false, -}; +comptime { + // Ensure that checking for the prefix should be a cheap lookup (bun.strings.hasPrefixComptime) + // because 24 bytes == 8 * 3 --> read and compare three u64s + bun.assert(import_path.len % 8 == 0); +} pub const FallbackModule = struct { path: Fs.Path, - code: string, package_json: *const PackageJSON, + code: string, - pub const assert = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(assert_import_path, "node", "assert"), - .code = assert_code, - .package_json = &assert_package_json, - }; - pub const buffer = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(buffer_import_path, "node", "buffer"), - .code = buffer_code, - .package_json = &buffer_package_json, - }; - pub const console = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(console_import_path, "node", "console"), - .code = console_code, - .package_json = &console_package_json, - }; - pub const constants = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(constants_import_path, "node", "constants"), - .code = constants_code, - .package_json = &constants_package_json, - }; - pub const crypto = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(crypto_import_path, "node", "crypto"), - .code = crypto_code, - .package_json = &crypto_package_json, - }; - pub const domain = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(domain_import_path, "node", "domain"), - .code = domain_code, - .package_json = &domain_package_json, - }; - pub const events = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(events_import_path, "node", "events"), - .code = events_code, - .package_json = &events_package_json, - }; - pub const http = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(http_import_path, "node", "http"), - .code = http_code, - .package_json = &http_package_json, - }; - pub const https = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(https_import_path, "node", "https"), - .code = https_code, - .package_json = &https_package_json, - }; - pub const net = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(net_import_path, "node", "net"), - .code = net_code, - .package_json = &net_package_json, - }; - pub const os = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(os_import_path, "node", "os"), - .code = os_code, - .package_json = &os_package_json, - }; - pub const path = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(path_import_path, "node", "path"), - .code = path_code, - .package_json = &path_package_json, - }; - pub const process = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(process_import_path, "node", "process"), - .code = process_code, - .package_json = &process_package_json, - }; - pub const punycode = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(punycode_import_path, "node", "punycode"), - .code = punycode_code, - .package_json = &punycode_package_json, - }; - pub const querystring = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(querystring_import_path, "node", "querystring"), - .code = querystring_code, - .package_json = &querystring_package_json, - }; - pub const stream = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(stream_import_path, "node", "stream"), - .code = stream_code, - .package_json = &stream_package_json, - }; - pub const string_decoder = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(string_decoder_import_path, "node", "string_decoder"), - .code = string_decoder_code, - .package_json = &string_decoder_package_json, - }; - pub const sys = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(sys_import_path, "node", "sys"), - .code = sys_code, - .package_json = &sys_package_json, - }; - pub const timers = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(timers_import_path, "node", "timers"), - .code = timers_code, - .package_json = &timers_package_json, - }; - pub const tty = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(tty_import_path, "node", "tty"), - .code = tty_code, - .package_json = &tty_package_json, - }; - pub const url = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(url_import_path, "node", "url"), - .code = url_code, - .package_json = &url_package_json, - }; - pub const util = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(util_import_path, "node", "util"), - .code = util_code, - .package_json = &util_package_json, - }; - pub const zlib = FallbackModule{ - .path = Fs.Path.initWithNamespaceVirtual(zlib_import_path, "node", "zlib"), - .code = zlib_code, - .package_json = &zlib_package_json, - }; + pub fn init(comptime name: string) FallbackModule { + @setEvalBranchQuota(99999); + const version = "0.0.0-polyfill"; + const code_path = "node-fallbacks/" ++ name ++ ".js"; + return .{ + .path = Fs.Path.initWithNamespaceVirtual(import_path ++ name ++ "/index.js", "node", name), + .package_json = &PackageJSON{ + .name = name, + .version = version, + .module_type = .esm, + .hash = @as(u32, @truncate(bun.hash(name ++ "@" ++ version))), + .main_fields = undefined, + .browser_map = undefined, + .source = logger.Source.initPathString(import_path ++ name ++ "/package.json", ""), + .side_effects = .false, + }, + .code = @embedFile(code_path), + }; + } }; pub const Map = bun.ComptimeStringMap(FallbackModule, .{ - .{ "assert", FallbackModule.assert }, - .{ "buffer", FallbackModule.buffer }, - .{ "console", FallbackModule.console }, - .{ "constants", FallbackModule.constants }, - .{ "crypto", FallbackModule.crypto }, - .{ "domain", FallbackModule.domain }, - .{ "events", FallbackModule.events }, - .{ "http", FallbackModule.http }, - .{ "https", FallbackModule.https }, - .{ "net", FallbackModule.net }, - .{ "os", FallbackModule.os }, - .{ "path", FallbackModule.path }, - .{ "process", FallbackModule.process }, - .{ "punycode", FallbackModule.punycode }, - .{ "querystring", FallbackModule.querystring }, - .{ "stream", FallbackModule.stream }, - .{ "string_decoder", FallbackModule.string_decoder }, - .{ "sys", FallbackModule.sys }, - .{ "timers", FallbackModule.timers }, - .{ "tty", FallbackModule.tty }, - .{ "url", FallbackModule.url }, - .{ "util", FallbackModule.util }, - .{ "zlib", FallbackModule.zlib }, + .{ "assert", FallbackModule.init("assert") }, + .{ "buffer", FallbackModule.init("buffer") }, + .{ "console", FallbackModule.init("console") }, + .{ "constants", FallbackModule.init("constants") }, + .{ "crypto", FallbackModule.init("crypto") }, + .{ "domain", FallbackModule.init("domain") }, + .{ "events", FallbackModule.init("events") }, + .{ "http", FallbackModule.init("http") }, + .{ "https", FallbackModule.init("https") }, + .{ "net", FallbackModule.init("net") }, + .{ "os", FallbackModule.init("os") }, + .{ "path", FallbackModule.init("path") }, + .{ "process", FallbackModule.init("process") }, + .{ "punycode", FallbackModule.init("punycode") }, + .{ "querystring", FallbackModule.init("querystring") }, + .{ "stream", FallbackModule.init("stream") }, + .{ "string_decoder", FallbackModule.init("string_decoder") }, + .{ "sys", FallbackModule.init("sys") }, + .{ "timers", FallbackModule.init("timers") }, + .{ "tty", FallbackModule.init("tty") }, + .{ "url", FallbackModule.init("url") }, + .{ "util", FallbackModule.init("util") }, + .{ "zlib", FallbackModule.init("zlib") }, }); pub fn contentsFromPath(path: string) ?string { - @setCold(true); - var module_name = path["/bun-vfs/node_modules/".len..]; + if (Environment.allow_assert) + bun.assert(bun.strings.hasPrefixComptime(path, import_path)); - if (module_name[0] == '@') { - var end = std.mem.indexOfScalar(u8, module_name, '/').? + 1; - end += std.mem.indexOfScalar(u8, module_name[end..], '/').?; - - module_name = module_name[0..end]; - } else { - module_name = module_name[0..std.mem.indexOfScalar(u8, module_name, '/').?]; - } + var module_name = path[import_path.len..]; + module_name = module_name[0 .. std.mem.indexOfScalar(u8, module_name, '/') orelse module_name.len]; if (Map.get(module_name)) |mod| { return mod.code; } + return null; } - -pub const buffer_fallback_import_name: string = "node:buffer"; diff --git a/src/runtime.zig b/src/runtime.zig index 9b6d6e8b9b..6e5f12d9a3 100644 --- a/src/runtime.zig +++ b/src/runtime.zig @@ -16,8 +16,6 @@ const Schema = @import("./api/schema.zig"); const Ref = @import("ast/base.zig").Ref; const JSAst = bun.JSAst; const content = @import("root").content; -// packages/bun-cli-*/bun -const BUN_ROOT = "../../"; const Api = Schema.Api; fn embedDebugFallback(comptime msg: []const u8, comptime code: []const u8) []const u8 { @@ -31,50 +29,8 @@ fn embedDebugFallback(comptime msg: []const u8, comptime code: []const u8) []con return code; } -pub const ErrorCSS = struct { - pub inline fn sourceContent() string { - if (comptime Environment.isDebug) { - var out_buffer: bun.PathBuffer = undefined; - const dirname = std.fs.selfExeDirPath(&out_buffer) catch unreachable; - var paths = [_]string{ dirname, BUN_ROOT, content.error_css_path }; - const file = std.fs.cwd().openFile( - resolve_path.joinAbsString(dirname, &paths, .auto), - .{ .mode = .read_only }, - ) catch return embedDebugFallback( - "Missing packages/bun-error/bun-error.css. Please run \"make bun_error\"", - content.error_css, - ); - defer file.close(); - return file.readToEndAlloc(default_allocator, file.getEndPos() catch 0) catch unreachable; - } else { - return content.error_css; - } - } -}; - -pub const ErrorJS = struct { - pub inline fn sourceContent() string { - if (comptime Environment.isDebug) { - var out_buffer: bun.PathBuffer = undefined; - const dirname = std.fs.selfExeDirPath(&out_buffer) catch unreachable; - var paths = [_]string{ dirname, BUN_ROOT, content.error_js_path }; - const file = std.fs.cwd().openFile( - resolve_path.joinAbsString(dirname, &paths, .auto), - .{ .mode = .read_only }, - ) catch return embedDebugFallback( - "Missing " ++ content.error_js_path ++ ". Please run \"make bun_error\"", - content.error_js, - ); - defer file.close(); - return file.readToEndAlloc(default_allocator, file.getEndPos() catch 0) catch unreachable; - } else { - return content.error_js; - } - } -}; pub const Fallback = struct { - pub const ProdSourceContent = @embedFile("./fallback.out.js"); pub const HTMLTemplate = @embedFile("./fallback.html"); pub const HTMLBackendTemplate = @embedFile("./fallback-backend.html"); @@ -113,29 +69,27 @@ pub const Fallback = struct { }; }; - pub inline fn scriptContent() string { - if (comptime Environment.isDebug) { - const dirpath = comptime bun.Environment.base_path ++ "/" ++ (bun.Dirname.dirname(u8, @src().file) orelse ""); - var buf: bun.PathBuffer = undefined; - const user = bun.getUserName(&buf) orelse ""; - const dir = std.mem.replaceOwned( - u8, - default_allocator, - dirpath, - "jarred", - user, - ) catch unreachable; - const runtime_path = std.fs.path.join(default_allocator, &[_]string{ dir, "fallback.out.js" }) catch unreachable; - const file = std.fs.openFileAbsolute(runtime_path, .{}) catch return embedDebugFallback( - "Missing bun/src/fallback.out.js. " ++ "Please run \"make fallback_decoder\"", - ProdSourceContent, - ); - defer file.close(); - return file.readToEndAlloc(default_allocator, file.getEndPos() catch 0) catch unreachable; - } else { - return ProdSourceContent; - } + pub inline fn errorJS() string { + return if (Environment.codegen_embed) + @embedFile("bun-error/bun-error.css") + else + bun.runtimeEmbedFile(.codegen, "bun-error/bun-error.css"); } + + pub inline fn errorCSS() string { + return if (Environment.codegen_embed) + @embedFile("bun-error/bun-error.css") + else + bun.runtimeEmbedFile(.codegen, "bun-error/bun-error.css"); + } + + pub inline fn fallbackDecoderJS() string { + return if (Environment.codegen_embed) + @embedFile("fallback-decoder.js") + else + bun.runtimeEmbedFile(.codegen, "fallback-decoder.js"); + } + pub const version_hash = @import("build_options").fallback_html_version; var version_hash_int: u32 = 0; pub fn versionHash() u32 { @@ -166,7 +120,7 @@ pub const Fallback = struct { try writer.print(HTMLTemplate, PrintArgs{ .blob = Base64FallbackMessage{ .msg = msg, .allocator = allocator }, .preload = preload, - .fallback = scriptContent(), + .fallback = fallbackDecoderJS(), .entry_point = entry_point, }); } @@ -186,17 +140,16 @@ pub const Fallback = struct { }; try writer.print(HTMLBackendTemplate, PrintArgs{ .blob = Base64FallbackMessage{ .msg = msg, .allocator = allocator }, - .bun_error_css = ErrorCSS.sourceContent(), - .bun_error = ErrorJS.sourceContent(), + .bun_error_css = errorCSS(), + .bun_error = errorJS(), .bun_error_page_css = "", - .fallback = scriptContent(), + .fallback = fallbackDecoderJS(), }); } }; pub const Runtime = struct { - pub const source_code = @embedFile("./runtime.out.js"); - + pub const source_code = @embedFile("runtime.out.js"); pub const hash = brk: { @setEvalBranchQuota(source_code.len * 50); break :brk bun.Wyhash11.hash(0, source_code);