From adc86c773bc9c074b4700b191ecc85b846610340 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Thu, 3 Oct 2024 15:34:53 -0700 Subject: [PATCH] chore: rename kit -> bake (#14335) --- build.zig | 6 +- cmake/targets/BuildBun.cmake | 38 ++--- src/ast/base.zig | 4 +- .../BakeDevGlobalObject.cpp} | 10 +- .../BakeDevGlobalObject.h} | 10 +- .../BakeDevSourceProvider.cpp} | 26 ++-- .../BakeDevSourceProvider.h} | 20 +-- src/{kit => bake}/DevServer.zig | 44 +++--- src/{kit => bake}/bake.d.ts | 0 src/{kit => bake}/bake.private.d.ts | 0 src/{kit => bake}/bake.zig | 43 +++--- .../bun-framework-rsc/client.tsx | 0 .../bun-framework-rsc/server.tsx | 2 +- src/{kit => bake}/bun-framework-rsc/ssr.tsx | 0 src/{kit => bake}/client/overlay.css | 0 src/{kit => bake}/client/overlay.ts | 0 src/{kit => bake}/error.template.html | 0 src/{kit => bake}/hmr-module.ts | 0 src/{kit => bake}/hmr-protocol.md | 0 src/{kit => bake}/hmr-runtime-client.ts | 0 src/{kit => bake}/hmr-runtime-server.ts | 0 src/{kit => bake}/macros.ts | 0 src/{kit => bake}/package.json | 0 src/{kit => bake}/tsconfig.json | 0 .../bindings/webcore/DOMClientIsoSubspaces.h | 2 +- src/bun.js/bindings/webcore/DOMIsoSubspaces.h | 2 +- src/bun.js/javascript.zig | 6 +- src/bun.zig | 4 +- src/bundler/bundle_v2.zig | 145 +++++++++--------- src/cli.zig | 2 +- src/cli/build_command.zig | 6 +- .../{kit-codegen.ts => bake-codegen.ts} | 16 +- src/feature_flags.zig | 4 +- src/import_record.zig | 4 +- src/js_ast.zig | 2 +- src/js_parser.zig | 12 +- src/js_printer.zig | 22 +-- src/options.zig | 20 +-- src/resolver/resolver.zig | 3 +- src/runtime.zig | 4 +- ...t_dev.test.ts => bundler_bake_dev.test.ts} | 12 +- test/bundler/expectBundled.ts | 2 +- 42 files changed, 236 insertions(+), 235 deletions(-) rename src/{kit/KitDevGlobalObject.cpp => bake/BakeDevGlobalObject.cpp} (95%) rename src/{kit/KitDevGlobalObject.h => bake/BakeDevGlobalObject.h} (85%) rename src/{kit/KitSourceProvider.cpp => bake/BakeDevSourceProvider.cpp} (75%) rename src/{kit/KitSourceProvider.h => bake/BakeDevSourceProvider.h} (58%) rename src/{kit => bake}/DevServer.zig (98%) rename src/{kit => bake}/bake.d.ts (100%) rename src/{kit => bake}/bake.private.d.ts (100%) rename src/{kit => bake}/bake.zig (91%) rename src/{kit => bake}/bun-framework-rsc/client.tsx (100%) rename src/{kit => bake}/bun-framework-rsc/server.tsx (99%) rename src/{kit => bake}/bun-framework-rsc/ssr.tsx (100%) rename src/{kit => bake}/client/overlay.css (100%) rename src/{kit => bake}/client/overlay.ts (100%) rename src/{kit => bake}/error.template.html (100%) rename src/{kit => bake}/hmr-module.ts (100%) rename src/{kit => bake}/hmr-protocol.md (100%) rename src/{kit => bake}/hmr-runtime-client.ts (100%) rename src/{kit => bake}/hmr-runtime-server.ts (100%) rename src/{kit => bake}/macros.ts (100%) rename src/{kit => bake}/package.json (100%) rename src/{kit => bake}/tsconfig.json (100%) rename src/codegen/{kit-codegen.ts => bake-codegen.ts} (89%) rename test/bundler/{bundler_kit_dev.test.ts => bundler_bake_dev.test.ts} (81%) diff --git a/build.zig b/build.zig index bc92dc8ac7..9f664a5ec7 100644 --- a/build.zig +++ b/build.zig @@ -52,7 +52,7 @@ const BunBuildOptions = struct { /// instead of at compile time. This is disabled in release or if this flag /// is set (to allow CI to build a portable executable). Affected files: /// - /// - src/kit/runtime.ts (bundled) + /// - src/bake/runtime.ts (bundled) /// - src/bun.js/api/FFI.h /// /// A similar technique is used in C++ code for JavaScript builtins @@ -475,8 +475,8 @@ 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 = "kit.client.js", .import = "kit-codegen/kit.client.js", .enable = opts.shouldEmbedCode() }, - .{ .file = "kit.server.js", .import = "kit-codegen/kit.server.js", .enable = opts.shouldEmbedCode() }, + .{ .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() }, }) |entry| { if (!@hasField(@TypeOf(entry), "enable") or entry.enable) { const path = b.pathJoin(&.{ opts.generated_code_dir, entry.file }); diff --git a/cmake/targets/BuildBun.cmake b/cmake/targets/BuildBun.cmake index 5aa263f83a..9c24f0cb6b 100644 --- a/cmake/targets/BuildBun.cmake +++ b/cmake/targets/BuildBun.cmake @@ -324,41 +324,41 @@ register_command( ${BUN_JAVASCRIPT_OUTPUTS} ) -set(BUN_KIT_RUNTIME_CODEGEN_SCRIPT ${CWD}/src/codegen/kit-codegen.ts) +set(BUN_BAKE_RUNTIME_CODEGEN_SCRIPT ${CWD}/src/codegen/bake-codegen.ts) -file(GLOB_RECURSE BUN_KIT_RUNTIME_SOURCES ${CONFIGURE_DEPENDS} - ${CWD}/src/kit/*.ts - ${CWD}/src/kit/*/*.ts - ${CWD}/src/kit/*/*.css +file(GLOB_RECURSE BUN_BAKE_RUNTIME_SOURCES ${CONFIGURE_DEPENDS} + ${CWD}/src/bake/*.ts + ${CWD}/src/bake/*/*.ts + ${CWD}/src/bake/*/*.css ) -list(APPEND BUN_KIT_RUNTIME_CODEGEN_SOURCES +list(APPEND BUN_BAKE_RUNTIME_CODEGEN_SOURCES ${CWD}/src/bun.js/bindings/InternalModuleRegistry.cpp ) -set(BUN_KIT_RUNTIME_OUTPUTS - ${CODEGEN_PATH}/kit_empty_file - ${CODEGEN_PATH}/kit.client.js - ${CODEGEN_PATH}/kit.server.js +set(BUN_BAKE_RUNTIME_OUTPUTS + ${CODEGEN_PATH}/bake.client.js + ${CODEGEN_PATH}/bake.server.js ) register_command( TARGET - bun-kit-codegen + bun-bake-codegen COMMENT "Bundling Kit Runtime" COMMAND ${BUN_EXECUTABLE} run - ${BUN_KIT_RUNTIME_CODEGEN_SCRIPT} + ${BUN_BAKE_RUNTIME_CODEGEN_SCRIPT} --debug=${DEBUG} --codegen_root=${CODEGEN_PATH} SOURCES - ${BUN_KIT_RUNTIME_SOURCES} - ${BUN_KIT_RUNTIME_CODEGEN_SOURCES} - ${BUN_KIT_RUNTIME_CODEGEN_SCRIPT} + ${BUN_BAKE_RUNTIME_SOURCES} + ${BUN_BAKE_RUNTIME_CODEGEN_SOURCES} + ${BUN_BAKE_RUNTIME_CODEGEN_SCRIPT} OUTPUTS - ${BUN_KIT_RUNTIME_OUTPUTS} + ${CODEGEN_PATH}/bake_empty_file + ${BUN_BAKE_RUNTIME_OUTPUTS} ) set(BUN_JS_SINK_SCRIPT ${CWD}/src/codegen/generate-jssink.ts) @@ -503,9 +503,9 @@ set(BUN_ZIG_GENERATED_SOURCES # In debug builds, these are not embedded, but rather referenced at runtime. if (DEBUG) - list(APPEND BUN_ZIG_GENERATED_SOURCES ${CODEGEN_PATH}/kit_empty_file) + list(APPEND BUN_ZIG_GENERATED_SOURCES ${CODEGEN_PATH}/bake_empty_file) else() - list(APPEND BUN_ZIG_GENERATED_SOURCES ${BUN_KIT_RUNTIME_OUTPUTS}) + list(APPEND BUN_ZIG_GENERATED_SOURCES ${BUN_BAKE_RUNTIME_OUTPUTS}) endif() set(BUN_ZIG_OUTPUT ${BUILD_PATH}/bun-zig.o) @@ -574,7 +574,7 @@ file(GLOB BUN_CXX_SOURCES ${CONFIGURE_DEPENDS} ${CWD}/src/bun.js/bindings/webcrypto/*/*.cpp ${CWD}/src/bun.js/bindings/v8/*.cpp ${CWD}/src/bun.js/bindings/v8/shim/*.cpp - ${CWD}/src/kit/*.cpp + ${CWD}/src/bake/*.cpp ${CWD}/src/deps/*.cpp ${BUN_USOCKETS_SOURCE}/src/crypto/*.cpp ) diff --git a/src/ast/base.zig b/src/ast/base.zig index 2e4449a1ad..ffd6240ad3 100644 --- a/src/ast/base.zig +++ b/src/ast/base.zig @@ -47,8 +47,8 @@ pub const Index = packed struct(u32) { pub const invalid = Index{ .value = std.math.maxInt(Int) }; pub const runtime = Index{ .value = 0 }; - pub const kit_server_data = Index{ .value = 1 }; - pub const kit_client_data = Index{ .value = 2 }; + pub const bake_server_data = Index{ .value = 1 }; + pub const bake_client_data = Index{ .value = 2 }; pub const Int = u32; diff --git a/src/kit/KitDevGlobalObject.cpp b/src/bake/BakeDevGlobalObject.cpp similarity index 95% rename from src/kit/KitDevGlobalObject.cpp rename to src/bake/BakeDevGlobalObject.cpp index b23c84cc2e..365bd8928c 100644 --- a/src/kit/KitDevGlobalObject.cpp +++ b/src/bake/BakeDevGlobalObject.cpp @@ -1,13 +1,13 @@ -#include "KitDevGlobalObject.h" +#include "BakeDevGlobalObject.h" #include "JSNextTickQueue.h" #include "JavaScriptCore/GlobalObjectMethodTable.h" #include "JavaScriptCore/JSInternalPromise.h" #include "ProcessIdentifier.h" #include "headers-handwritten.h" -namespace Kit { +namespace Bake { -extern "C" void KitInitProcessIdentifier() { +extern "C" void BakeInitProcessIdentifier() { // assert is on main thread WebCore::Process::identifier(); } @@ -74,7 +74,7 @@ void DevGlobalObject::finishCreation(JSC::VM &vm) { extern "C" BunVirtualMachine *Bun__getVM(); // A lot of this function is taken from 'Zig__GlobalObject__create' -extern "C" DevGlobalObject *KitCreateDevGlobal(DevServer *owner, +extern "C" DevGlobalObject *BakeCreateDevGlobal(DevServer *owner, void *console) { JSC::VM &vm = JSC::VM::create(JSC::HeapType::Large).leakRef(); vm.heap.acquireAccess(); @@ -111,4 +111,4 @@ extern "C" DevGlobalObject *KitCreateDevGlobal(DevServer *owner, return global; } -}; // namespace Kit +}; // namespace Bake diff --git a/src/kit/KitDevGlobalObject.h b/src/bake/BakeDevGlobalObject.h similarity index 85% rename from src/kit/KitDevGlobalObject.h rename to src/bake/BakeDevGlobalObject.h index 851e8f07e7..3e36421aaf 100644 --- a/src/kit/KitDevGlobalObject.h +++ b/src/bake/BakeDevGlobalObject.h @@ -2,7 +2,7 @@ #include "root.h" #include "ZigGlobalObject.h" -namespace Kit { +namespace Bake { struct DevServer; // DevServer.zig struct Route; // DevServer.zig @@ -18,10 +18,10 @@ public: return nullptr; return WebCore::subspaceForImpl( vm, - [](auto& spaces) { return spaces.m_clientSubspaceForKitGlobalScope.get(); }, - [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForKitGlobalScope = std::forward(space); }, - [](auto& spaces) { return spaces.m_subspaceForKitGlobalScope.get(); }, - [](auto& spaces, auto&& space) { spaces.m_subspaceForKitGlobalScope = std::forward(space); }, + [](auto& spaces) { return spaces.m_clientSubspaceForBakeGlobalScope.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBakeGlobalScope = std::forward(space); }, + [](auto& spaces) { return spaces.m_subspaceForBakeGlobalScope.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForBakeGlobalScope = std::forward(space); }, [](auto& server) -> JSC::HeapCellType& { return server.m_heapCellTypeForJSWorkerGlobalScope; }); } diff --git a/src/kit/KitSourceProvider.cpp b/src/bake/BakeDevSourceProvider.cpp similarity index 75% rename from src/kit/KitSourceProvider.cpp rename to src/bake/BakeDevSourceProvider.cpp index a2e8f2b659..11a22fdda2 100644 --- a/src/kit/KitSourceProvider.cpp +++ b/src/bake/BakeDevSourceProvider.cpp @@ -1,5 +1,6 @@ // clang-format off -#include "KitSourceProvider.h" +#include "BakeDevSourceProvider.h" +#include "BakeDevGlobalObject.h" #include "JavaScriptCore/Completion.h" #include "JavaScriptCore/Identifier.h" #include "JavaScriptCore/JSCJSValue.h" @@ -9,17 +10,16 @@ #include "JavaScriptCore/JSModuleLoader.h" #include "JavaScriptCore/JSString.h" #include "JavaScriptCore/JSModuleNamespaceObject.h" -#include "KitDevGlobalObject.h" -namespace Kit { +namespace Bake { -extern "C" LoadServerCodeResult KitLoadInitialServerCode(DevGlobalObject* global, BunString source) { - JSC::VM&vm=global->vm(); +extern "C" LoadServerCodeResult BakeLoadInitialServerCode(DevGlobalObject* global, BunString source) { + JSC::VM& vm = global->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - String string = "kit://server.js"_s; + String string = "bake://server.js"_s; JSC::SourceOrigin origin = JSC::SourceOrigin(WTF::URL(string)); - JSC::SourceCode sourceCode = JSC::SourceCode(KitSourceProvider::create( + JSC::SourceCode sourceCode = JSC::SourceCode(DevSourceProvider::create( source.toWTFString(), origin, WTFMove(string), @@ -37,13 +37,13 @@ extern "C" LoadServerCodeResult KitLoadInitialServerCode(DevGlobalObject* global return { internalPromise, key }; } -extern "C" JSC::EncodedJSValue KitLoadServerHmrPatch(DevGlobalObject* global, BunString source) { +extern "C" JSC::EncodedJSValue BakeLoadServerHmrPatch(DevGlobalObject* global, BunString source) { JSC::VM&vm=global->vm(); auto scope = DECLARE_THROW_SCOPE(vm); - String string = "kit://server.patch.js"_s; + String string = "bake://server.patch.js"_s; JSC::SourceOrigin origin = JSC::SourceOrigin(WTF::URL(string)); - JSC::SourceCode sourceCode = JSC::SourceCode(KitSourceProvider::create( + JSC::SourceCode sourceCode = JSC::SourceCode(DevSourceProvider::create( source.toWTFString(), origin, WTFMove(string), @@ -58,7 +58,7 @@ extern "C" JSC::EncodedJSValue KitLoadServerHmrPatch(DevGlobalObject* global, Bu return JSC::JSValue::encode(result); } -extern "C" JSC::EncodedJSValue KitGetRequestHandlerFromModule( +extern "C" JSC::EncodedJSValue BakeGetRequestHandlerFromModule( DevGlobalObject* global, JSC::JSString* key ) { @@ -68,7 +68,7 @@ extern "C" JSC::EncodedJSValue KitGetRequestHandlerFromModule( vm, JSC::Identifier::fromString(global->vm(), "registry"_s) )); JSC::JSValue entry = map->get(global, key); - ASSERT(entry.isObject()); // should have called KitLoadServerCode and wait for that promise + ASSERT(entry.isObject()); // should have called BakeLoadServerCode and wait for that promise JSC::JSValue module = entry.getObject()->get(global, JSC::Identifier::fromString(global->vm(), "module"_s)); ASSERT(module.isCell()); JSC::JSModuleNamespaceObject* namespaceObject = global->moduleLoader()->getModuleNamespaceObject(global, module); @@ -76,4 +76,4 @@ extern "C" JSC::EncodedJSValue KitGetRequestHandlerFromModule( return JSC::JSValue::encode(namespaceObject->get(global, vm.propertyNames->defaultKeyword)); } -} // namespace Kit +} // namespace Bake diff --git a/src/kit/KitSourceProvider.h b/src/bake/BakeDevSourceProvider.h similarity index 58% rename from src/kit/KitSourceProvider.h rename to src/bake/BakeDevSourceProvider.h index 1063cd3d6b..a2adc606b7 100644 --- a/src/kit/KitSourceProvider.h +++ b/src/bake/BakeDevSourceProvider.h @@ -1,30 +1,30 @@ #pragma once #include "root.h" #include "headers-handwritten.h" -#include "KitDevGlobalObject.h" +#include "BakeDevGlobalObject.h" #include "JavaScriptCore/SourceOrigin.h" -namespace Kit { +namespace Bake { struct LoadServerCodeResult { JSC::JSInternalPromise* promise; JSC::JSString* key; }; -class KitSourceProvider final : public JSC::StringSourceProvider { +class DevSourceProvider final : public JSC::StringSourceProvider { public: - static Ref create( + static Ref create( const String& source, const JSC::SourceOrigin& sourceOrigin, String&& sourceURL, const TextPosition& startPosition, JSC::SourceProviderSourceType sourceType ) { - return adoptRef(*new KitSourceProvider(source, sourceOrigin, WTFMove(sourceURL), startPosition, sourceType)); + return adoptRef(*new DevSourceProvider(source, sourceOrigin, WTFMove(sourceURL), startPosition, sourceType)); } private: - KitSourceProvider( + DevSourceProvider( const String& source, const JSC::SourceOrigin& sourceOrigin, String&& sourceURL, @@ -41,8 +41,8 @@ private: }; // Zig API -extern "C" LoadServerCodeResult KitLoadInitialServerCode(DevGlobalObject* global, BunString source); -extern "C" JSC::EncodedJSValue KitLoadServerHmrPatch(DevGlobalObject* global, BunString source); -extern "C" JSC::EncodedJSValue KitGetRequestHandlerFromModule(DevGlobalObject* global, JSC::JSString* encodedModule); +extern "C" LoadServerCodeResult BakeLoadInitialServerCode(DevGlobalObject* global, BunString source); +extern "C" JSC::EncodedJSValue BakeLoadServerHmrPatch(DevGlobalObject* global, BunString source); +extern "C" JSC::EncodedJSValue BakeGetRequestHandlerFromModule(DevGlobalObject* global, JSC::JSString* encodedModule); -} // namespace Kit +} // namespace Bake diff --git a/src/kit/DevServer.zig b/src/bake/DevServer.zig similarity index 98% rename from src/kit/DevServer.zig rename to src/bake/DevServer.zig index aa6ce7e0b6..f7068b6ced 100644 --- a/src/kit/DevServer.zig +++ b/src/bake/DevServer.zig @@ -7,7 +7,7 @@ //! the remainder of this process' lifespan. Later, it will be required to fully //! clean up server state. pub const DevServer = @This(); -pub const debug = bun.Output.Scoped(.Kit, false); +pub const debug = bun.Output.Scoped(.Bake, false); pub const Options = struct { allocator: ?Allocator = null, // defaults to a named heap @@ -224,7 +224,7 @@ pub fn init(options: Options) !*DevServer { .args = std.mem.zeroes(bun.Schema.Api.TransformOptions), }) catch |err| Output.panic("Failed to create Global object: {}", .{err}); - dev.server_global = c.KitCreateDevGlobal(dev, dev.vm.console); + dev.server_global = c.BakeCreateDevGlobal(dev, dev.vm.console); dev.vm.global = dev.server_global.js(); dev.vm.regular_event_loop.global = dev.vm.global; dev.vm.jsc = dev.vm.global.vm(); @@ -289,7 +289,7 @@ fn initBundler(dev: *DevServer, bundler: *Bundler, comptime renderer: bake.Rende }; bundler.options.entry_points = &.{}; bundler.options.log = &dev.log; - bundler.options.output_format = .internal_kit_dev; + bundler.options.output_format = .internal_bake_dev; bundler.options.out_extensions = bun.StringHashMap([]const u8).init(bundler.allocator); bundler.options.hot_module_reloading = true; @@ -311,7 +311,7 @@ fn initBundler(dev: *DevServer, bundler: *Bundler, comptime renderer: bake.Rende bundler.options.minify_identifiers = false; bundler.options.minify_whitespace = false; - bundler.options.kit = dev; + bundler.options.dev_server = dev; bundler.options.framework = &dev.framework; bundler.configureLinker(); @@ -507,7 +507,7 @@ fn theRealBundlingFunction( const abs_path = file.path.text; if (!std.fs.path.isAbsolute(abs_path)) continue; - switch (target.kitRenderer()) { + switch (target.bakeRenderer()) { .server => { _ = dev.server_graph.insertStale(abs_path, false) catch bun.outOfMemory(); }, @@ -571,7 +571,7 @@ fn theRealBundlingFunction( if (server_bundle.len > 0) { if (is_first_server_chunk) { - const server_code = c.KitLoadInitialServerCode(dev.server_global, bun.String.createLatin1(server_bundle)) catch |err| { + const server_code = c.BakeLoadInitialServerCode(dev.server_global, bun.String.createLatin1(server_bundle)) catch |err| { fail.* = Failure.fromJSServerLoad(dev.server_global.js().takeException(err), dev.server_global.js()); return error.ServerJSLoad; }; @@ -586,7 +586,7 @@ fn theRealBundlingFunction( .fulfilled => |v| bun.assert(v == .undefined), } - const default_export = c.KitGetRequestHandlerFromModule(dev.server_global, server_code.key); + const default_export = c.BakeGetRequestHandlerFromModule(dev.server_global, server_code.key); if (!default_export.isObject()) @panic("Internal assertion failure: expected interface from HMR runtime to be an object"); const fetch_function: JSValue = default_export.get(dev.server_global.js(), "handleRequest") orelse @@ -600,7 +600,7 @@ fn theRealBundlingFunction( fetch_function.ensureStillAlive(); register_update.ensureStillAlive(); } else { - const server_code = c.KitLoadServerHmrPatch(dev.server_global, bun.String.createLatin1(server_bundle)) catch |err| { + const server_code = c.BakeLoadServerHmrPatch(dev.server_global, bun.String.createLatin1(server_bundle)) catch |err| { // No user code has been evaluated yet, since everything is to // be wrapped in a function clousure. This means that the likely // error is going to be a syntax error, or other mistake in the @@ -780,7 +780,7 @@ fn onServerRequestWithBundle(route: *Route, bundle: Bundle, req: *Request, resp: const bun_string = result.toBunString(dev.server_global.js()); defer bun_string.deref(); if (bun_string.tag == .Dead) { - bun.todoPanic(@src(), "Kit: support non-string return value", .{}); + bun.todoPanic(@src(), "Bake: support non-string return value", .{}); } const utf8 = bun_string.toUTF8(dev.allocator); @@ -836,7 +836,7 @@ fn sendBuiltInNotFound(resp: *Response) void { resp.end(message, true); } -/// The paradigm of Kit's incremental state is to store a separate list of files +/// The paradigm of Bake's incremental state is to store a separate list of files /// than the Graph in bundle_v2. When watch events happen, the bundler is run on /// the changed files, excluding non-stale files via `isFileStale`. /// @@ -1169,7 +1169,7 @@ pub fn IncrementalGraph(side: bake.Side) type { if (g.current_chunk_len == 0) return ""; const runtime = switch (kind) { - .initial_response => bun.kit.getHmrRuntime(side), + .initial_response => bun.bake.getHmrRuntime(side), .hmr_chunk => "({\n", }; @@ -1745,7 +1745,7 @@ const DevWebSocket = struct { } }; -/// Kit uses a special global object extending Zig::GlobalObject +/// Bake uses a special global object extending Zig::GlobalObject pub const DevGlobalObject = opaque { /// Safe downcast to use other Bun APIs pub fn js(ptr: *DevGlobalObject) *JSC.JSGlobalObject { @@ -1757,23 +1757,23 @@ pub const DevGlobalObject = opaque { } }; -pub const KitSourceProvider = opaque {}; +pub const BakeSourceProvider = opaque {}; const c = struct { - // KitDevGlobalObject.cpp - extern fn KitCreateDevGlobal(owner: *DevServer, console: *JSC.ConsoleObject) *DevGlobalObject; + // BakeDevGlobalObject.cpp + extern fn BakeCreateDevGlobal(owner: *DevServer, console: *JSC.ConsoleObject) *DevGlobalObject; - // KitSourceProvider.cpp - extern fn KitGetRequestHandlerFromModule(global: *DevGlobalObject, module: *JSC.JSString) JSValue; + // BakeSourceProvider.cpp + extern fn BakeGetRequestHandlerFromModule(global: *DevGlobalObject, module: *JSC.JSString) JSValue; const LoadServerCodeResult = struct { promise: *JSInternalPromise, key: *JSC.JSString, }; - fn KitLoadServerHmrPatch(global: *DevGlobalObject, code: bun.String) !JSValue { + fn BakeLoadServerHmrPatch(global: *DevGlobalObject, code: bun.String) !JSValue { const f = @extern(*const fn (*DevGlobalObject, bun.String) callconv(.C) JSValue, .{ - .name = "KitLoadServerHmrPatch", + .name = "BakeLoadServerHmrPatch", }); const result = f(global, code); if (result == .zero) { @@ -1783,13 +1783,13 @@ const c = struct { return result; } - fn KitLoadInitialServerCode(global: *DevGlobalObject, code: bun.String) bun.JSError!LoadServerCodeResult { + fn BakeLoadInitialServerCode(global: *DevGlobalObject, code: bun.String) bun.JSError!LoadServerCodeResult { const Return = extern struct { promise: ?*JSInternalPromise, key: *JSC.JSString, }; const f = @extern(*const fn (*DevGlobalObject, bun.String) callconv(.C) Return, .{ - .name = "KitLoadInitialServerCode", + .name = "BakeLoadInitialServerCode", }); const result = f(global, code); return .{ @@ -2070,7 +2070,7 @@ const bun = @import("root").bun; const Environment = bun.Environment; const assert = bun.assert; -const bake = bun.kit; +const bake = bun.bake; const Log = bun.logger.Log; diff --git a/src/kit/bake.d.ts b/src/bake/bake.d.ts similarity index 100% rename from src/kit/bake.d.ts rename to src/bake/bake.d.ts diff --git a/src/kit/bake.private.d.ts b/src/bake/bake.private.d.ts similarity index 100% rename from src/kit/bake.private.d.ts rename to src/bake/bake.private.d.ts diff --git a/src/kit/bake.zig b/src/bake/bake.zig similarity index 91% rename from src/kit/bake.zig rename to src/bake/bake.zig index 1afd6f8cdc..541045446a 100644 --- a/src/kit/bake.zig +++ b/src/bake/bake.zig @@ -3,14 +3,12 @@ //! server, server components, and other integrations. Instead of taking the //! role as a framework, Bake is tool for frameworks to build on top of. -// TODO: rename all references from Kit to Bake - /// Temporary function to invoke dev server via JavaScript. Will be /// replaced with a user-facing API. Refs the event loop forever. pub fn jsWipDevServer(global: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSValue { - if (!bun.FeatureFlags.kit) return .undefined; + if (!bun.FeatureFlags.bake) return .undefined; - KitInitProcessIdentifier(); + BakeInitProcessIdentifier(); bun.Output.warn( \\Be advised that Bun Bake is highly experimental, and its API @@ -37,7 +35,7 @@ pub fn jsWipDevServer(global: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JS } } -extern fn KitInitProcessIdentifier() void; +extern fn BakeInitProcessIdentifier() void; /// A "Framework" in our eyes is simply set of bundler options that a framework /// author would set in order to integrate the framework with the application. @@ -75,9 +73,9 @@ pub const Framework = struct { .{ .code = @embedFile("./bun-framework-rsc/server.tsx") }, .{ .code = @embedFile("./bun-framework-rsc/ssr.tsx") }, } else &.{ - .{ .code = bun.runtimeEmbedFile(.src, "kit/bun-framework-rsc/client.tsx") }, - .{ .code = bun.runtimeEmbedFile(.src, "kit/bun-framework-rsc/server.tsx") }, - .{ .code = bun.runtimeEmbedFile(.src, "kit/bun-framework-rsc/ssr.tsx") }, + .{ .code = bun.runtimeEmbedFile(.src, "bake/bun-framework-rsc/client.tsx") }, + .{ .code = bun.runtimeEmbedFile(.src, "bake/bun-framework-rsc/server.tsx") }, + .{ .code = bun.runtimeEmbedFile(.src, "bake/bun-framework-rsc/ssr.tsx") }, }) catch bun.outOfMemory(), }; } @@ -145,7 +143,7 @@ pub const Framework = struct { // TODO: This function always leaks memory. // `Framework` has no way to specify what is allocated, nor should it. - fn fromJS(opts: JSValue, global: JSC.JSGlobalObject) !Framework { + fn fromJS(opts: JSValue, global: *JSC.JSGlobalObject) !Framework { if (opts.isString()) { const str = opts.toBunString(global); defer str.deref(); @@ -165,7 +163,7 @@ pub const Framework = struct { global.throwInvalidArguments("Missing 'framework.serverEntryPoint'", .{}); return error.JSError; }; - const str = prop.toBunString(); + const str = prop.toBunString(global); defer str.deref(); if (global.hasException()) @@ -180,7 +178,7 @@ pub const Framework = struct { global.throwInvalidArguments("Missing 'framework.clientEntryPoint'", .{}); return error.JSError; }; - const str = prop.toBunString(); + const str = prop.toBunString(global); defer str.deref(); if (global.hasException()) @@ -213,6 +211,7 @@ pub const Framework = struct { if (rfr == .null or rfr == .undefined) break :sc null; break :sc .{ + .client_runtime_import = "", .separate_ssr_graph = brk: { const prop: JSValue = opts.get(global, "separateSSRGraph") orelse { if (!global.hasException()) @@ -230,7 +229,7 @@ pub const Framework = struct { global.throwInvalidArguments("Missing 'framework.serverComponents.serverRuntimeImportSource'", .{}); return error.JSError; }; - const str = prop.toBunString(); + const str = prop.toBunString(global); defer str.deref(); if (global.hasException()) @@ -245,7 +244,7 @@ pub const Framework = struct { global.throwInvalidArguments("Missing 'framework.serverComponents.serverRegisterClientReferenceExport'", .{}); return error.JSError; }; - const str = prop.toBunString(); + const str = prop.toBunString(global); defer str.deref(); if (global.hasException()) @@ -291,15 +290,19 @@ fn devServerOptionsFromJs(global: *JSC.JSGlobalObject, options: JSValue) !DevSer }; } + const framework_js = options.get(global, "framework") orelse { + return error.Invalid; + }; + const framework = try Framework.fromJS(framework_js, global); return .{ .cwd = bun.getcwdAlloc(bun.default_allocator) catch bun.outOfMemory(), .routes = routes, - .framework = Framework.react(), + .framework = framework, }; } export fn Bun__getTemporaryDevServer(global: *JSC.JSGlobalObject) JSValue { - if (!bun.FeatureFlags.kit) return .undefined; + if (!bun.FeatureFlags.bake) return .undefined; return JSC.JSFunction.create(global, "wipDevServer", bun.JSC.toJSHostFunction(jsWipDevServer), 0, .{}); } @@ -319,11 +322,11 @@ pub fn wipDevServer(options: DevServer.Options) noreturn { pub fn getHmrRuntime(mode: Side) []const u8 { return if (Environment.embed_code) switch (mode) { - .client => @embedFile("kit-codegen/kit.client.js"), - .server => @embedFile("kit-codegen/kit.server.js"), + .client => @embedFile("bake-codegen/bake.client.js"), + .server => @embedFile("bake-codegen/bake.server.js"), } else switch (mode) { - inline else => |m| bun.runtimeEmbedFile(.codegen, "kit." ++ @tagName(m) ++ ".js"), + inline else => |m| bun.runtimeEmbedFile(.codegen, "bake." ++ @tagName(m) ++ ".js"), }; } @@ -367,14 +370,14 @@ pub const server_virtual_source: bun.logger.Source = .{ .path = bun.fs.Path.initForKitBuiltIn("bun", "bake/server"), .key_path = bun.fs.Path.initForKitBuiltIn("bun", "bake/server"), .contents = "", // Virtual - .index = bun.JSAst.Index.kit_server_data, + .index = bun.JSAst.Index.bake_server_data, }; pub const client_virtual_source: bun.logger.Source = .{ .path = bun.fs.Path.initForKitBuiltIn("bun", "bake/client"), .key_path = bun.fs.Path.initForKitBuiltIn("bun", "bake/client"), .contents = "", // Virtual - .index = bun.JSAst.Index.kit_client_data, + .index = bun.JSAst.Index.bake_client_data, }; pub const DevServer = @import("./DevServer.zig"); diff --git a/src/kit/bun-framework-rsc/client.tsx b/src/bake/bun-framework-rsc/client.tsx similarity index 100% rename from src/kit/bun-framework-rsc/client.tsx rename to src/bake/bun-framework-rsc/client.tsx diff --git a/src/kit/bun-framework-rsc/server.tsx b/src/bake/bun-framework-rsc/server.tsx similarity index 99% rename from src/kit/bun-framework-rsc/server.tsx rename to src/bake/bun-framework-rsc/server.tsx index d923d68e0a..03c418b381 100644 --- a/src/kit/bun-framework-rsc/server.tsx +++ b/src/bake/bun-framework-rsc/server.tsx @@ -1,6 +1,6 @@ import type { Bake } from "bun"; import { renderToReadableStream } from "react-server-dom-webpack/server.browser"; -import { renderToHtml } from "bun-framework-rsc/ssr.tsx" with { bunKitGraph: "ssr" }; +import { renderToHtml } from "bun-framework-rsc/ssr.tsx" with { bunBakeGraph: "ssr" }; import { serverManifest } from "bun:bake/server"; // `server.tsx` exports a function to be used for handling user routes. It takes diff --git a/src/kit/bun-framework-rsc/ssr.tsx b/src/bake/bun-framework-rsc/ssr.tsx similarity index 100% rename from src/kit/bun-framework-rsc/ssr.tsx rename to src/bake/bun-framework-rsc/ssr.tsx diff --git a/src/kit/client/overlay.css b/src/bake/client/overlay.css similarity index 100% rename from src/kit/client/overlay.css rename to src/bake/client/overlay.css diff --git a/src/kit/client/overlay.ts b/src/bake/client/overlay.ts similarity index 100% rename from src/kit/client/overlay.ts rename to src/bake/client/overlay.ts diff --git a/src/kit/error.template.html b/src/bake/error.template.html similarity index 100% rename from src/kit/error.template.html rename to src/bake/error.template.html diff --git a/src/kit/hmr-module.ts b/src/bake/hmr-module.ts similarity index 100% rename from src/kit/hmr-module.ts rename to src/bake/hmr-module.ts diff --git a/src/kit/hmr-protocol.md b/src/bake/hmr-protocol.md similarity index 100% rename from src/kit/hmr-protocol.md rename to src/bake/hmr-protocol.md diff --git a/src/kit/hmr-runtime-client.ts b/src/bake/hmr-runtime-client.ts similarity index 100% rename from src/kit/hmr-runtime-client.ts rename to src/bake/hmr-runtime-client.ts diff --git a/src/kit/hmr-runtime-server.ts b/src/bake/hmr-runtime-server.ts similarity index 100% rename from src/kit/hmr-runtime-server.ts rename to src/bake/hmr-runtime-server.ts diff --git a/src/kit/macros.ts b/src/bake/macros.ts similarity index 100% rename from src/kit/macros.ts rename to src/bake/macros.ts diff --git a/src/kit/package.json b/src/bake/package.json similarity index 100% rename from src/kit/package.json rename to src/bake/package.json diff --git a/src/kit/tsconfig.json b/src/bake/tsconfig.json similarity index 100% rename from src/kit/tsconfig.json rename to src/bake/tsconfig.json diff --git a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h index 05b9f567c6..3ba6b4c6e2 100644 --- a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h @@ -906,7 +906,7 @@ public: // std::unique_ptr m_clientSubspaceForXPathResult; // std::unique_ptr m_clientSubspaceForXSLTProcessor; - std::unique_ptr m_clientSubspaceForKitGlobalScope; + std::unique_ptr m_clientSubspaceForBakeGlobalScope; std::unique_ptr m_clientSubspaceForAbortController; std::unique_ptr m_clientSubspaceForAbortSignal; diff --git a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h index e5bab0e470..e86f18bfd5 100644 --- a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h @@ -899,7 +899,7 @@ public: // std::unique_ptr m_subspaceForXPathResult; // std::unique_ptr m_subspaceForXSLTProcessor; - std::unique_ptr m_subspaceForKitGlobalScope; + std::unique_ptr m_subspaceForBakeGlobalScope; std::unique_ptr m_subspaceForAbortController; std::unique_ptr m_subspaceForAbortSignal; diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 9cd7e1a11e..b669b54554 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -4167,7 +4167,7 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime pub const HotReloadTask = struct { count: u8 = 0, hashes: [8]u32, - paths: if (Ctx == bun.kit.DevServer) [8][]const u8 else void, + paths: if (Ctx == bun.bake.DevServer) [8][]const u8 else void, /// Left uninitialized until .enqueue concurrent_task: JSC.ConcurrentTask, reloader: *Reloader, @@ -4177,7 +4177,7 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime .reloader = reloader, .hashes = [_]u32{0} ** 8, - .paths = if (Ctx == bun.kit.DevServer) [_][]const u8{&.{}} ** 8, + .paths = if (Ctx == bun.bake.DevServer) [_][]const u8{&.{}} ** 8, .count = 0, .concurrent_task = undefined, }; @@ -4191,7 +4191,7 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime this.hashes[this.count] = id; // TODO(@paperdave/bake): this allocation is terrible and must be removed - if (Ctx == bun.kit.DevServer) + if (Ctx == bun.bake.DevServer) this.paths[this.count] = default_allocator.dupe(u8, path) catch bun.outOfMemory(); this.count += 1; } diff --git a/src/bun.zig b/src/bun.zig index 8c04726e61..928a260083 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -3762,9 +3762,7 @@ pub fn memmove(output: []u8, input: []const u8) void { pub const hmac = @import("./hmac.zig"); pub const libdeflate = @import("./deps/libdeflate.zig"); -/// Deprecated: use `bun.bake` -pub const kit = bake; -pub const bake = @import("kit/bake.zig"); +pub const bake = @import("bake/bake.zig"); /// like std.enums.tagName, except it doesn't lose the sentinel value. pub fn tagName(comptime Enum: type, value: Enum) ?[:0]const u8 { diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index ed5966b967..88900b5c35 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -127,7 +127,7 @@ const debugPartRanges = Output.scoped(.PartRanges, true); const BitSet = bun.bit_set.DynamicBitSetUnmanaged; const Async = bun.Async; const Loc = Logger.Loc; -const kit = bun.kit; +const bake = bun.bake; const logPartDependencyTree = Output.scoped(.part_dep_tree, false); @@ -331,10 +331,10 @@ pub const BundleV2 = struct { /// When Server Component is enabled, this is used for the client bundles /// and `bundler` is used for the server bundles. client_bundler: *Bundler, - /// See kit.Framework.ServerComponents.separate_ssr_graph + /// See bake.Framework.ServerComponents.separate_ssr_graph ssr_bundler: *Bundler, - /// When Bun Kit is used, the resolved framework is passed here - framework: ?kit.Framework, + /// When Bun Bake is used, the resolved framework is passed here + framework: ?bake.Framework, graph: Graph, linker: LinkerContext, bun_watcher: ?*bun.JSC.Watcher, @@ -352,7 +352,7 @@ pub const BundleV2 = struct { dynamic_import_entry_points: std.AutoArrayHashMap(Index.Int, void) = undefined, const KitOptions = struct { - framework: kit.Framework, + framework: bake.Framework, client_bundler: *Bundler, ssr_bundler: *Bundler, }; @@ -569,7 +569,7 @@ pub const BundleV2 = struct { ) catch |err| { // Only perform directory busting when hot-reloading is enabled if (err == error.ModuleNotFound) { - if (this.bundler.options.kit) |dev| { + if (this.bundler.options.dev_server) |dev| { if (!had_busted_dir_cache) { // Only re-query if we previously had something cached. if (bundler.resolver.bustDirCacheFromSpecifier(import_record.source_file, import_record.specifier)) { @@ -582,7 +582,7 @@ pub const BundleV2 = struct { dev.directory_watchers.trackResolutionFailure( import_record.source_file, import_record.specifier, - target.kitRenderer(), + target.bakeRenderer(), ) catch bun.outOfMemory(); } } @@ -839,10 +839,10 @@ pub const BundleV2 = struct { this.bundler.log.msgs.allocator = this.graph.allocator; this.bundler.log.clone_line_text = true; - // We don't expose an option to disable this. Kit requires tree-shaking - // disabled since every export must is always exist in case a future - // module starts depending on it. - if (this.bundler.options.output_format == .internal_kit_dev) { + // We don't expose an option to disable this. Bake forbids tree-shaking + // since every export must is always exist in case a future module + // starts depending on it. + if (this.bundler.options.output_format == .internal_bake_dev) { this.bundler.options.tree_shaking = false; this.bundler.resolver.opts.tree_shaking = false; } else { @@ -865,7 +865,7 @@ pub const BundleV2 = struct { this.linker.options.public_path = bundler.options.public_path; this.linker.options.target = bundler.options.target; this.linker.options.output_format = bundler.options.output_format; - this.linker.kit_dev_server = bundler.options.kit; + this.linker.dev_server = bundler.options.dev_server; this.graph.generate_bytecode_cache = bundler.options.bytecode; @@ -913,8 +913,8 @@ pub const BundleV2 = struct { batch.push(ThreadPoolLib.Batch.from(&runtime_parse_task.task)); } - // Kit has two source indexes which are computed at the end of the - // Scan+Parse phase, but reserved now so that resolution works. + // Bake reserves two source indexes at the start of the file list, but + // gets its content set after the scan+parse phase, but before linking. try this.reserveSourceIndexesForKit(); { @@ -972,7 +972,7 @@ pub const BundleV2 = struct { /// This generates the two asts for 'bun:bake/client' and 'bun:bake/server'. Both are generated /// at the same time in one pass over the SBC list. pub fn processServerComponentManifestFiles(this: *BundleV2) OOM!void { - // If Kit is not being used, do nothing + // If a server components is not configured, do nothing const fw = this.framework orelse return; const sc = fw.server_components orelse return; @@ -981,8 +981,8 @@ pub const BundleV2 = struct { const alloc = this.graph.allocator; - var server = try AstBuilder.init(this.graph.allocator, &kit.server_virtual_source, this.bundler.options.hot_module_reloading); - var client = try AstBuilder.init(this.graph.allocator, &kit.client_virtual_source, this.bundler.options.hot_module_reloading); + var server = try AstBuilder.init(this.graph.allocator, &bake.server_virtual_source, this.bundler.options.hot_module_reloading); + var client = try AstBuilder.init(this.graph.allocator, &bake.client_virtual_source, this.bundler.options.hot_module_reloading); var server_manifest_props: std.ArrayListUnmanaged(G.Property) = .{}; var client_manifest_props: std.ArrayListUnmanaged(G.Property) = .{}; @@ -1014,7 +1014,7 @@ pub const BundleV2 = struct { // re-generate this file later with the properly decided // manifest. However, I will probably reconsider how this // manifest is being generated when I write the whole - // "production build" part of Kit. + // "production build" part of Bake. const keys = named_exports_array[source_id].keys(); const client_manifest_items = try alloc.alloc(G.Property, keys.len); @@ -1087,8 +1087,8 @@ pub const BundleV2 = struct { .is_export = true, }); - this.graph.ast.set(Index.kit_server_data.get(), try server.toBundledAst(.bun)); - this.graph.ast.set(Index.kit_client_data.get(), try client.toBundledAst(.browser)); + this.graph.ast.set(Index.bake_server_data.get(), try server.toBundledAst(.bun)); + this.graph.ast.set(Index.bake_client_data.get(), try client.toBundledAst(.browser)); } pub fn enqueueParseTask( @@ -1988,8 +1988,8 @@ pub const BundleV2 = struct { try this.graph.ast.ensureUnusedCapacity(this.graph.allocator, 2); try this.graph.input_files.ensureUnusedCapacity(this.graph.allocator, 2); - const server_source = kit.server_virtual_source; - const client_source = kit.client_virtual_source; + const server_source = bake.server_virtual_source; + const client_source = bake.client_virtual_source; this.graph.input_files.appendAssumeCapacity(.{ .source = server_source, @@ -2002,8 +2002,8 @@ pub const BundleV2 = struct { .side_effects = .no_side_effects__pure_data, }); - bun.assert(this.graph.input_files.items(.source)[Index.kit_server_data.get()].index.get() == Index.kit_server_data.get()); - bun.assert(this.graph.input_files.items(.source)[Index.kit_client_data.get()].index.get() == Index.kit_client_data.get()); + bun.assert(this.graph.input_files.items(.source)[Index.bake_server_data.get()].index.get() == Index.bake_server_data.get()); + bun.assert(this.graph.input_files.items(.source)[Index.bake_client_data.get()].index.get() == Index.bake_client_data.get()); this.graph.ast.appendAssumeCapacity(JSAst.empty); this.graph.ast.appendAssumeCapacity(JSAst.empty); @@ -2054,7 +2054,7 @@ pub const BundleV2 = struct { if (this.framework) |fw| if (fw.server_components != null) { switch (ast.target.isServerSide()) { inline else => |is_server| { - const src = if (is_server) kit.server_virtual_source else kit.client_virtual_source; + const src = if (is_server) bake.server_virtual_source else bake.client_virtual_source; if (strings.eqlComptime(import_record.path.text, src.path.pretty)) { if (is_server) { this.graph.kit_referenced_server_data = true; @@ -2123,8 +2123,8 @@ pub const BundleV2 = struct { continue; } - const bundler, const renderer: kit.Renderer, const target = - if (import_record.tag == .kit_resolve_to_ssr_graph) + const bundler, const renderer: bake.Renderer, const target = + if (import_record.tag == .bake_resolve_to_ssr_graph) brk: { // TODO: consider moving this error into js_parser so it is caught more reliably // Then we can assert(this.framework != null) @@ -2133,7 +2133,7 @@ pub const BundleV2 = struct { source, import_record.range.loc, this.graph.allocator, - "The 'bun_kit_graph' import attribute cannot be used outside of a Bun Kit bundle", + "The 'bunBakeGraph' import attribute cannot be used outside of a Bun Bake bundle", .{}, ) catch @panic("unexpected log error"); continue; @@ -2159,7 +2159,7 @@ pub const BundleV2 = struct { }; } else .{ this.bundlerForTarget(ast.target), - ast.target.kitRenderer(), + ast.target.bakeRenderer(), ast.target, }; @@ -2171,7 +2171,7 @@ pub const BundleV2 = struct { ) catch |err| { // Only perform directory busting when hot-reloading is enabled if (err == error.ModuleNotFound) { - if (this.bundler.options.kit) |dev| { + if (this.bundler.options.dev_server) |dev| { if (!had_busted_dir_cache) { // Only re-query if we previously had something cached. if (bundler.resolver.bustDirCacheFromSpecifier( @@ -2187,7 +2187,7 @@ pub const BundleV2 = struct { dev.directory_watchers.trackResolutionFailure( source.path.text, import_record.path.text, - ast.target.kitRenderer(), // use the source file target not the altered one + ast.target.bakeRenderer(), // use the source file target not the altered one ) catch bun.outOfMemory(); } } @@ -2266,7 +2266,7 @@ pub const BundleV2 = struct { continue; } - if (this.bundler.options.kit) |dev_server| { + if (this.bundler.options.dev_server) |dev_server| { // TODO(paperdave/kit): this relative can be done without a clone in most cases if (!dev_server.isFileStale(path.text, renderer)) { import_record.source_index = Index.invalid; @@ -2602,7 +2602,7 @@ pub const BundleV2 = struct { /// Used to keep the bundle thread from spinning on Windows pub fn timerCallback(_: *bun.windows.libuv.Timer) callconv(.C) void {} -/// Originally, kit.DevServer required a separate bundling thread, but that was +/// Originally, bake.DevServer required a separate bundling thread, but that was /// later removed. The bundling thread's scheduling logic is generalized over /// the completion structure. /// @@ -2634,8 +2634,7 @@ pub fn BundleThread(CompletionStruct: type) type { } /// Lazily-initialized singleton. This is used for `Bun.build` since the - /// bundle thread may not be needed. Kit always uses the bundler, so it - /// just initializes `BundleThread` + /// bundle thread may not be needed. pub const singleton = struct { var once = std.once(loadOnceImpl); var instance: ?*Self = null; @@ -3337,7 +3336,7 @@ pub const ParseTask = struct { opts.features.allow_runtime = !source.index.isRuntime(); opts.features.unwrap_commonjs_to_esm = output_format == .esm and FeatureFlags.unwrap_commonjs_to_esm; opts.features.use_import_meta_require = target.isBun(); - opts.features.top_level_await = output_format == .esm or output_format == .internal_kit_dev; + opts.features.top_level_await = output_format == .esm or output_format == .internal_bake_dev; opts.features.auto_import_jsx = task.jsx.parse and bundler.options.auto_import_jsx; opts.features.trim_unused_imports = loader.isTypeScript() or (bundler.options.trim_unused_imports orelse false); opts.features.inlining = bundler.options.minify_syntax; @@ -3346,7 +3345,7 @@ pub const ParseTask = struct { opts.features.minify_identifiers = bundler.options.minify_identifiers; opts.features.emit_decorator_metadata = bundler.options.emit_decorator_metadata; opts.features.unwrap_commonjs_packages = bundler.options.unwrap_commonjs_packages; - opts.features.hot_module_reloading = output_format == .internal_kit_dev and !source.index.isRuntime(); + opts.features.hot_module_reloading = output_format == .internal_bake_dev and !source.index.isRuntime(); opts.features.react_fast_refresh = target == .browser and bundler.options.react_fast_refresh and loader.isJSX() and @@ -4536,9 +4535,9 @@ pub const LinkerContext = struct { /// to know whether or not we can free it safely. pending_task_count: std.atomic.Value(u32) = std.atomic.Value(u32).init(0), - /// Used by Kit to extract []CompileResult before it is joined - kit_dev_server: ?*bun.kit.DevServer = null, - framework: ?*const kit.Framework = null, + /// Used by Bake to extract []CompileResult before it is joined + dev_server: ?*bun.bake.DevServer = null, + framework: ?*const bake.Framework = null, pub const LinkerOptions = struct { output_format: options.Format = .esm, @@ -4838,7 +4837,7 @@ pub const LinkerContext = struct { // The dev server never compiles chunks, and requires every reachable // file to be printed, So the logic is special-cased. - if (this.kit_dev_server != null) { + if (this.dev_server != null) { var js_chunks = try std.ArrayListUnmanaged(Chunk).initCapacity(this.allocator, 1); const entry_bits = &this.graph.files.items(.entry_bits)[0]; @@ -5817,7 +5816,7 @@ pub const LinkerContext = struct { count += "init_".len + ident_fmt_len; } - if (wrap != .cjs and export_kind != .cjs and output_format != .internal_kit_dev) { + if (wrap != .cjs and export_kind != .cjs and output_format != .internal_bake_dev) { count += "exports_".len + ident_fmt_len; count += "module_".len + ident_fmt_len; } @@ -5865,7 +5864,7 @@ pub const LinkerContext = struct { // actual CommonJS files from being renamed. This is purely about // aesthetics and is not about correctness. This is done here because by // this point, we know the CommonJS status will not change further. - if (wrap != .cjs and export_kind != .cjs and output_format != .internal_kit_dev) { + if (wrap != .cjs and export_kind != .cjs and output_format != .internal_bake_dev) { const exports_name = builder.fmt("exports_{}", .{source.fmtIdentifier()}); const module_name = builder.fmt("module_{}", .{source.fmtIdentifier()}); @@ -6013,7 +6012,7 @@ pub const LinkerContext = struct { this.graph.meta.items(.entry_point_part_index)[id] = Index.part(entry_point_part_index); // Pull in the "__toCommonJS" symbol if we need it due to being an entry point - if (force_include_exports and output_format != .internal_kit_dev) { + if (force_include_exports and output_format != .internal_bake_dev) { this.graph.generateRuntimeSymbolImportAndUse( source_index, Index.part(entry_point_part_index), @@ -6040,7 +6039,7 @@ pub const LinkerContext = struct { // Don't follow external imports (this includes import() expressions) if (!record.source_index.isValid() or this.isExternalDynamicImport(record, source_index)) { - if (output_format == .internal_kit_dev) continue; + if (output_format == .internal_bake_dev) continue; // This is an external import. Check if it will be a "require()" call. if (kind == .require or !output_format.keepES6ImportExportSyntax() or kind == .dynamic) { @@ -6111,7 +6110,7 @@ pub const LinkerContext = struct { // This is an ES6 import of a CommonJS module, so it needs the // "__toESM" wrapper as long as it's not a bare "require()" - if (kind != .require and other_export_kind == .cjs and output_format != .internal_kit_dev) { + if (kind != .require and other_export_kind == .cjs and output_format != .internal_bake_dev) { record.wrap_with_to_esm = true; to_esm_uses += 1; } @@ -6207,7 +6206,7 @@ pub const LinkerContext = struct { } } - if (output_format != .internal_kit_dev) { + if (output_format != .internal_bake_dev) { // If there's an ES6 import of a CommonJS module, then we're going to need the // "__toESM" symbol from the runtime to wrap the result of "require()" this.graph.generateRuntimeSymbolImportAndUse( @@ -6490,7 +6489,7 @@ pub const LinkerContext = struct { // Initialize the part that was allocated for us earlier. The information // here will be used after this during tree shaking. c.graph.ast.items(.parts)[id].slice()[js_ast.namespace_export_part_index] = .{ - .stmts = if (c.options.output_format != .internal_kit_dev) all_export_stmts else &.{}, + .stmts = if (c.options.output_format != .internal_bake_dev) all_export_stmts else &.{}, .symbol_uses = ns_export_symbol_uses, .dependencies = js_ast.Dependency.List.fromList(ns_export_dependencies), .declared_symbols = declared_symbols, @@ -7552,10 +7551,10 @@ pub const LinkerContext = struct { const trace = tracer(@src(), "generateCodeForFileInChunkJS"); defer trace.end(); - // Client bundles for Kit must be globally allocated, + // Client bundles for Bake must be globally allocated, // as it must outlive the bundle task. - const use_global_allocator = c.kit_dev_server != null and - c.parse_graph.ast.items(.target)[part_range.source_index.get()].kitRenderer() == .client; + const use_global_allocator = c.dev_server != null and + c.parse_graph.ast.items(.target)[part_range.source_index.get()].bakeRenderer() == .client; var arena = &worker.temporary_arena; var buffer_writer = js_printer.BufferWriter.init( @@ -7756,7 +7755,7 @@ pub const LinkerContext = struct { // For Kit, hoist runtime.js outside of the IIFE const compile_results = chunk.compile_results_for_chunk; - if (c.options.output_format == .internal_kit_dev) { + if (c.options.output_format == .internal_bake_dev) { for (compile_results) |compile_result| { const source_index = compile_result.sourceIndex(); if (source_index != Index.runtime.value) break; @@ -7766,8 +7765,8 @@ pub const LinkerContext = struct { } switch (c.options.output_format) { - .internal_kit_dev => { - const start = bun.kit.getHmrRuntime(if (c.options.target.isBun()) .server else .client); + .internal_bake_dev => { + const start = bun.bake.getHmrRuntime(if (c.options.target.isBun()) .server else .client); j.pushStatic(start); line_offset.advance(start); }, @@ -7826,7 +7825,7 @@ pub const LinkerContext = struct { CommentType.single; if (!c.options.minify_whitespace and - (output_format == .iife or output_format == .internal_kit_dev)) + (output_format == .iife or output_format == .internal_bake_dev)) { j.pushStatic(" "); line_offset.advance(" "); @@ -7859,7 +7858,7 @@ pub const LinkerContext = struct { } if (is_runtime) { - if (c.options.output_format != .internal_kit_dev) { + if (c.options.output_format != .internal_bake_dev) { line_offset.advance(compile_result.code()); j.push(compile_result.code(), bun.default_allocator); } @@ -7913,7 +7912,7 @@ pub const LinkerContext = struct { j.pushStatic(with_newline); }, - .internal_kit_dev => { + .internal_bake_dev => { { const str = "}, {\n main: "; j.pushStatic(str); @@ -8646,7 +8645,7 @@ pub const LinkerContext = struct { // TODO: iife .iife => {}, - .internal_kit_dev => { + .internal_bake_dev => { // nothing needs to be done here, as the exports are already // forwarded in the module closure. }, @@ -9625,7 +9624,7 @@ pub const LinkerContext = struct { // - export wrapping is already done. // - import wrapping needs to know resolved paths // - one part range per file (ensured by another special cased code path in findAllImportedPartsInJSOrder) - if (c.options.output_format == .internal_kit_dev) { + if (c.options.output_format == .internal_bake_dev) { bun.assert(!part_range.source_index.isRuntime()); // embedded in HMR runtime for (parts) |part| { @@ -10216,7 +10215,7 @@ pub const LinkerContext = struct { .indent = .{}, .commonjs_named_exports = ast.commonjs_named_exports, .commonjs_named_exports_ref = ast.exports_ref, - .commonjs_module_ref = if (ast.flags.uses_module_ref or c.options.output_format == .internal_kit_dev) + .commonjs_module_ref = if (ast.flags.uses_module_ref or c.options.output_format == .internal_bake_dev) ast.module_ref else Ref.None, @@ -10246,7 +10245,7 @@ pub const LinkerContext = struct { .line_offset_tables = c.graph.files.items(.line_offset_table)[source_index.get()], .target = c.options.target, - .input_files_for_kit = if (c.options.output_format == .internal_kit_dev) + .input_files_for_dev_server = if (c.options.output_format == .internal_bake_dev) c.parse_graph.input_files.items(.source) else null, @@ -10362,7 +10361,7 @@ pub const LinkerContext = struct { "Part Range: {s} {s} ({d}..{d})", .{ c.parse_graph.input_files.items(.source)[part_range.source_index.get()].path.pretty, - @tagName(c.parse_graph.ast.items(.target)[part_range.source_index.get()].kitRenderer()), + @tagName(c.parse_graph.ast.items(.target)[part_range.source_index.get()].bakeRenderer()), part_range.part_index_begin, part_range.part_index_end, }, @@ -10395,7 +10394,7 @@ pub const LinkerContext = struct { c.source_maps.quoted_contents_tasks.len = 0; } - // When kit.DevServer is in use, we're going to take a different code path at the end. + // When bake.DevServer is in use, we're going to take a different code path at the end. // We want to extract the source code of each part instead of combining it into a single file. // This is so that when hot-module updates happen, we can: // @@ -10404,7 +10403,7 @@ pub const LinkerContext = struct { // // When this isnt the initial bundle, concatenation as usual would produce a // broken module. It is DevServer's job to create and send HMR patches. - if (c.kit_dev_server) |dev_server| { + if (c.dev_server) |dev_server| { const input_file_sources = c.parse_graph.input_files.items(.source); const import_records = c.parse_graph.ast.items(.import_records); const targets = c.parse_graph.ast.items(.target); @@ -10430,7 +10429,7 @@ pub const LinkerContext = struct { try dev_server.receiveChunk( &ctx, part_range.source_index, - targets[part_range.source_index.get()].kitRenderer(), + targets[part_range.source_index.get()].bakeRenderer(), compile_result, ); } @@ -10440,7 +10439,7 @@ pub const LinkerContext = struct { try dev_server.processChunkDependencies( &ctx, part_range.source_index, - targets[part_range.source_index.get()].kitRenderer(), + targets[part_range.source_index.get()].bakeRenderer(), c.allocator, ); } @@ -11282,7 +11281,7 @@ pub const LinkerContext = struct { .{ entry_points_count, c.parse_graph.input_files.items(.source)[source_index].path.pretty, - @tagName(c.parse_graph.ast.items(.target)[source_index].kitRenderer()), + @tagName(c.parse_graph.ast.items(.target)[source_index].bakeRenderer()), out_dist, }, ); @@ -11333,7 +11332,7 @@ pub const LinkerContext = struct { debugTreeShake("markFileLiveForTreeShaking({d}, {s} {s}) = {s}", .{ source_index, c.parse_graph.input_files.get(source_index).source.path.pretty, - @tagName(c.parse_graph.ast.items(.target)[source_index].kitRenderer()), + @tagName(c.parse_graph.ast.items(.target)[source_index].bakeRenderer()), if (c.graph.files_live.isSet(source_index)) "already seen" else "first seen", }); } @@ -11806,7 +11805,7 @@ pub const LinkerContext = struct { } // Generate a dummy part that depends on the "__commonJS" symbol. - const dependencies: []js_ast.Dependency = if (c.options.output_format != .internal_kit_dev) brk: { + const dependencies: []js_ast.Dependency = if (c.options.output_format != .internal_bake_dev) brk: { const dependencies = c.allocator.alloc(js_ast.Dependency, common_js_parts.len) catch bun.outOfMemory(); for (common_js_parts, dependencies) |part, *cjs| { cjs.* = .{ @@ -11841,8 +11840,8 @@ pub const LinkerContext = struct { bun.assert(part_index != js_ast.namespace_export_part_index); wrapper_part_index.* = Index.part(part_index); - // Kit uses a wrapping approach that does not use __commonJS - if (c.options.output_format != .internal_kit_dev) { + // Bake uses a wrapping approach that does not use __commonJS + if (c.options.output_format != .internal_bake_dev) { c.graph.generateSymbolImportAndUse( source_index, part_index, @@ -11864,7 +11863,7 @@ pub const LinkerContext = struct { // // This depends on the "__esm" symbol and declares the "init_foo" symbol // for similar reasons to the CommonJS closure above. - const esm_parts = if (wrapper_ref.isValid() and c.options.output_format != .internal_kit_dev) + const esm_parts = if (wrapper_ref.isValid() and c.options.output_format != .internal_bake_dev) c.topLevelSymbolsToPartsForRuntime(c.esm_runtime_ref) else &.{}; @@ -11896,7 +11895,7 @@ pub const LinkerContext = struct { ) catch unreachable; bun.assert(part_index != js_ast.namespace_export_part_index); wrapper_part_index.* = Index.part(part_index); - if (wrapper_ref.isValid() and c.options.output_format != .internal_kit_dev) { + if (wrapper_ref.isValid() and c.options.output_format != .internal_bake_dev) { c.graph.generateSymbolImportAndUse( source_index, part_index, diff --git a/src/cli.zig b/src/cli.zig index 0e89506460..28dfc67eee 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -874,7 +874,7 @@ pub const Arguments = struct { }; switch (format) { - .internal_kit_dev => { + .internal_bake_dev => { bun.Output.warn("--format={s} is for debugging only, and may experience breaking changes at any moment", .{format_str}); bun.Output.flush(); }, diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig index b1a1c64f51..bb73ea1e15 100644 --- a/src/cli/build_command.zig +++ b/src/cli/build_command.zig @@ -100,7 +100,7 @@ pub const BuildCommand = struct { this_bundler.options.output_dir = ctx.bundler_options.outdir; this_bundler.options.output_format = ctx.bundler_options.output_format; - if (ctx.bundler_options.output_format == .internal_kit_dev) { + if (ctx.bundler_options.output_format == .internal_bake_dev) { this_bundler.options.tree_shaking = false; } @@ -237,8 +237,8 @@ pub const BuildCommand = struct { null, ); - try bun.kit.addImportMetaDefines(allocator, this_bundler.options.define, .development, .server); - try bun.kit.addImportMetaDefines(allocator, client_bundler.options.define, .development, .client); + try bun.bake.addImportMetaDefines(allocator, this_bundler.options.define, .development, .server); + try bun.bake.addImportMetaDefines(allocator, client_bundler.options.define, .development, .client); this_bundler.resolver.opts = this_bundler.options; client_bundler.resolver.opts = client_bundler.options; diff --git a/src/codegen/kit-codegen.ts b/src/codegen/bake-codegen.ts similarity index 89% rename from src/codegen/kit-codegen.ts rename to src/codegen/bake-codegen.ts index 88f4d35e71..57d698c147 100644 --- a/src/codegen/kit-codegen.ts +++ b/src/codegen/bake-codegen.ts @@ -21,13 +21,13 @@ if (!codegen_root) { } if (debug === "false" || debug === "0" || debug == "OFF") debug = false; -const kit_dir = join(import.meta.dirname, "../kit"); -process.chdir(kit_dir); // to make bun build predictable in development +const base_dir = join(import.meta.dirname, "../bake"); +process.chdir(base_dir); // to make bun build predictable in development const results = await Promise.allSettled( ["client", "server"].map(async side => { let result = await Bun.build({ - entrypoints: [join(kit_dir, `hmr-runtime-${side}.ts`)], + entrypoints: [join(base_dir, `hmr-runtime-${side}.ts`)], define: { side: JSON.stringify(side), IS_BUN_DEVELOPMENT: String(!!debug), @@ -54,7 +54,7 @@ const results = await Promise.allSettled( __marker__(${in_names.join(",")}); ${code}; `; - const generated_entrypoint = join(kit_dir, `.runtime-${side}.generated.ts`); + const generated_entrypoint = join(base_dir, `.runtime-${side}.generated.ts`); writeFileSync(generated_entrypoint, combined_source); using _ = { [Symbol.dispose] : () => { @@ -101,7 +101,7 @@ const results = await Promise.allSettled( code = `export default await ${code}`; } - writeFileSync(join(codegen_root, `kit.${side}.js`), code); + writeFileSync(join(codegen_root, `bake.${side}.js`), code); }), ); @@ -140,14 +140,14 @@ if (failed.length > 0) { for (const { kind, err } of flattened_errors) { if (kind !== current) { const map = { both: "runtime", client: "client runtime", server: "server runtime" }; - console.error(`Errors while bundling Kit ${map[kind]}:`); + console.error(`Errors while bundling HMR ${map[kind]}:`); } console.error(err); } process.exit(1); } else { - console.log("-> kit.client.js, kit.server.js"); + console.log("-> bake.client.js, bake.server.js"); - const empty_file = join(codegen_root, "kit_empty_file"); + const empty_file = join(codegen_root, "bake_empty_file"); if (!existsSync(empty_file)) writeFileSync(empty_file, "this is used to fulfill a cmake dependency"); } diff --git a/src/feature_flags.zig b/src/feature_flags.zig index c02c0ac35f..eecfa45a16 100644 --- a/src/feature_flags.zig +++ b/src/feature_flags.zig @@ -159,10 +159,10 @@ pub fn isLibdeflateEnabled() bool { } /// Enable Bun Kit's experimental bundler tools -pub const kit = env.is_canary or env.isDebug; +pub const bake = env.is_canary or env.isDebug; /// Enable --server-components -pub const cli_server_components = kit; +pub const cli_server_components = bake; /// Enable CSS handling in `bun build` pub const css = env.is_canary or env.isDebug; diff --git a/src/import_record.zig b/src/import_record.zig index 9125d18f35..aad8e12205 100644 --- a/src/import_record.zig +++ b/src/import_record.zig @@ -190,8 +190,8 @@ pub const ImportRecord = struct { react_server_component, /// For Bun Kit, if a module in the server graph should actually - /// crossover to the SSR graph. See kit.Framework.ServerComponents.separate_ssr_graph - kit_resolve_to_ssr_graph, + /// crossover to the SSR graph. See bake.Framework.ServerComponents.separate_ssr_graph + bake_resolve_to_ssr_graph, with_type_sqlite, with_type_sqlite_embedded, diff --git a/src/js_ast.zig b/src/js_ast.zig index 9a3651f87c..05a451fbff 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -8604,7 +8604,7 @@ pub const ServerComponentBoundary = struct { /// server's code. For server actions, this is the client's code. reference_source_index: Index.Int, - /// When `kit.Framework.ServerComponents.separate_ssr_graph` is enabled this + /// When `bake.Framework.ServerComponents.separate_ssr_graph` is enabled this /// points to the separated module. When the SSR graph is not separate, this is /// equal to `reference_source_index` // diff --git a/src/js_parser.zig b/src/js_parser.zig index 2d5a3167d2..3b2fe86d7a 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -9207,7 +9207,7 @@ fn NewParser_( } } } - } else if (import_tag == .kit_resolve_to_ssr_graph) { + } else if (import_tag == .bake_resolve_to_ssr_graph) { p.import_records.items[stmt.import_record_index].tag = import_tag; } } @@ -12217,7 +12217,7 @@ fn NewParser_( const SupportedAttribute = enum { type, embed, - bunKitGraph, + bunBakeGraph, }; var has_seen_embed_true = false; @@ -12280,11 +12280,11 @@ fn NewParser_( } } }, - .bunKitGraph => { + .bunBakeGraph => { if (strings.eqlComptime(p.lexer.string_literal_slice, "ssr")) { - path.import_tag = .kit_resolve_to_ssr_graph; + path.import_tag = .bake_resolve_to_ssr_graph; } else { - try p.lexer.addRangeError(p.lexer.range(), "'bunKitGraph' can only be set to 'ssr'", .{}, true); + try p.lexer.addRangeError(p.lexer.range(), "'bunBakeGraph' can only be set to 'ssr'", .{}, true); } }, } @@ -23272,7 +23272,7 @@ fn NewParser_( }); for (parts) |part| { - // Kit does not care about 'import =', as it handles it on it's own + // Bake does not care about 'import =', as it handles it on it's own _ = try ImportScanner.scan(P, p, part.stmts, wrap_mode != .none, true, &hmr_transform_ctx); } diff --git a/src/js_printer.zig b/src/js_printer.zig index 5bc363937f..33d381f17d 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -503,7 +503,7 @@ pub const Options = struct { target: options.Target = .browser, runtime_transpiler_cache: ?*bun.JSC.RuntimeTranspilerCache = null, - input_files_for_kit: ?[]logger.Source = null, + input_files_for_dev_server: ?[]logger.Source = null, commonjs_named_exports: js_ast.Ast.CommonJSNamedExports = .{}, commonjs_named_exports_deoptimized: bool = false, @@ -2002,8 +2002,8 @@ fn NewPrinter( p.print("("); } - if (p.options.input_files_for_kit) |input_files| { - bun.assert(module_type == .internal_kit_dev); + if (p.options.input_files_for_dev_server) |input_files| { + bun.assert(module_type == .internal_bake_dev); p.printSpaceBeforeIdentifier(); p.printSymbol(p.options.commonjs_module_ref); p.print(".require("); @@ -2075,7 +2075,7 @@ fn NewPrinter( const wrap_with_to_esm = record.wrap_with_to_esm; - if (module_type == .internal_kit_dev) { + if (module_type == .internal_bake_dev) { p.printSpaceBeforeIdentifier(); p.printSymbol(p.options.commonjs_module_ref); if (record.tag == .builtin) @@ -2321,7 +2321,7 @@ fn NewPrinter( .e_import_meta => { p.printSpaceBeforeIdentifier(); p.addSourceMapping(expr.loc); - if (p.options.module_type == .internal_kit_dev) { + if (p.options.module_type == .internal_bake_dev) { p.printSymbol(p.options.commonjs_module_ref); p.print(".importMeta()"); } else if (!p.options.import_meta_ref.isValid()) { @@ -2352,7 +2352,7 @@ fn NewPrinter( } p.print("import.meta.main"); } else { - bun.assert(p.options.module_type != .internal_kit_dev); + bun.assert(p.options.module_type != .internal_bake_dev); p.printSpaceBeforeIdentifier(); p.addSourceMapping(expr.loc); @@ -2619,7 +2619,7 @@ fn NewPrinter( p.printSpaceBeforeIdentifier(); p.addSourceMapping(expr.loc); - if (p.options.module_type == .internal_kit_dev) { + if (p.options.module_type == .internal_bake_dev) { p.printSymbol(p.options.commonjs_module_ref); p.print(".dynamicImport("); } else { @@ -3102,7 +3102,7 @@ fn NewPrinter( // Potentially use a property access instead of an identifier var didPrint = false; - const ref = if (p.options.module_type != .internal_kit_dev) + const ref = if (p.options.module_type != .internal_bake_dev) p.symbols().follow(e.ref) else e.ref; @@ -3193,7 +3193,7 @@ fn NewPrinter( // } if (!didPrint) { - // assert(p.options.module_type != .internal_kit_dev); + // assert(p.options.module_type != .internal_bake_dev); p.printSpaceBeforeIdentifier(); p.addSourceMapping(expr.loc); p.printSymbol(e.ref); @@ -3709,7 +3709,7 @@ fn NewPrinter( }, .e_import_identifier => |e| inner: { const ref = p.symbols().follow(e.ref); - if (p.options.input_files_for_kit != null) + if (p.options.input_files_for_dev_server != null) break :inner; // if (p.options.const_values.count() > 0 and p.options.const_values.contains(ref)) // break :inner; @@ -6330,7 +6330,7 @@ pub fn printWithWriterAndPlatform( imported_module_ids_list = printer.imported_module_ids; } - if (opts.module_type == .internal_kit_dev) { + if (opts.module_type == .internal_bake_dev) { printer.indent(); printer.printIndent(); printer.print('"'); diff --git a/src/options.zig b/src/options.zig index b29371dba3..ecebd1801c 100644 --- a/src/options.zig +++ b/src/options.zig @@ -384,7 +384,7 @@ pub const Target = enum { bun_macro, node, - /// This is used by kit.Framework.ServerComponents.separate_ssr_graph + /// This is used by bake.Framework.ServerComponents.separate_ssr_graph kit_server_components_ssr, pub const Map = bun.ComptimeStringMap(Target, .{ @@ -441,7 +441,7 @@ pub const Target = enum { }; } - pub fn kitRenderer(target: Target) bun.kit.Renderer { + pub fn bakeRenderer(target: Target) bun.bake.Renderer { return switch (target) { .browser => .client, .kit_server_components_ssr => .ssr, @@ -580,8 +580,8 @@ pub const Format = enum { /// CommonJS cjs, - /// Kit's uses a special module format for Hot-module-reloading. It includes a - /// runtime payload, sourced from src/kit/hmr-runtime.ts. + /// Bake uses a special module format for Hot-module-reloading. It includes a + /// runtime payload, sourced from src/bake/hmr-runtime-{side}.ts. /// /// ((input_graph, config) => { /// ... runtime code ... @@ -589,7 +589,7 @@ pub const Format = enum { /// "module1.ts"(module) { ... }, /// "module2.ts"(module) { ... }, /// }, { metadata }); - internal_kit_dev, + internal_bake_dev, pub fn keepES6ImportExportSyntax(this: Format) bool { return this == .esm; @@ -609,7 +609,7 @@ pub const Format = enum { .{ "iife", .iife }, // TODO: Disable this outside of debug builds - .{ "internal_kit_dev", .internal_kit_dev }, + .{ "internal_bake_dev", .internal_bake_dev }, }); pub fn fromJS(global: *JSC.JSGlobalObject, format: JSC.JSValue, exception: JSC.C.ExceptionRef) ?Format { @@ -1494,11 +1494,11 @@ pub const BundleOptions = struct { compile: bool = false, - /// Set when kit.DevServer is bundling. This changes the interface of the + /// Set when bake.DevServer is bundling. This changes the interface of the /// bundler from emitting OutputFile to only emitting []CompileResult - kit: ?*bun.kit.DevServer = null, - /// Set when Kit is bundling. Affects module resolution. - framework: ?*bun.kit.Framework = null, + dev_server: ?*bun.bake.DevServer = null, + /// Set when Bake is bundling. Affects module resolution. + framework: ?*bun.bake.Framework = null, /// This is a list of packages which even when require() is used, we will /// instead convert to ESM import statements. diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index a1ae54f1dc..80a33827c2 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -911,7 +911,8 @@ pub const Resolver = struct { } } - /// Runs a resolution but also checking if a Bun Kit framework has an override. This is used in one place in the bundler. + /// Runs a resolution but also checking if a Bun Bake framework has an + /// override. This is used in one place in the bundler. pub fn resolveWithFramework(r: *ThisResolver, source_dir: string, import_path: string, kind: ast.ImportKind) !Result { if (r.opts.framework) |f| { if (f.built_in_modules.get(import_path)) |mod| { diff --git a/src/runtime.zig b/src/runtime.zig index 932ecfd505..9b6d6e8b9b 100644 --- a/src/runtime.zig +++ b/src/runtime.zig @@ -210,8 +210,8 @@ pub const Runtime = struct { /// is documented in js_parser, search for `const ReactRefresh` react_fast_refresh: bool = false, - /// `hot_module_reloading` is specific to if we are using bun.kit.DevServer. - /// It can be enabled on the command line with --format=internal_kit_dev + /// `hot_module_reloading` is specific to if we are using bun.bake.DevServer. + /// It can be enabled on the command line with --format=internal_bake_dev /// /// Standalone usage of this flag / usage of this flag /// without '--format' set is an unsupported use case. diff --git a/test/bundler/bundler_kit_dev.test.ts b/test/bundler/bundler_bake_dev.test.ts similarity index 81% rename from test/bundler/bundler_kit_dev.test.ts rename to test/bundler/bundler_bake_dev.test.ts index 01396c3873..a2ecedfca6 100644 --- a/test/bundler/bundler_kit_dev.test.ts +++ b/test/bundler/bundler_bake_dev.test.ts @@ -2,12 +2,12 @@ import { describe } from "bun:test"; import { itBundled } from "./expectBundled"; describe("bundler", async () => { - itBundled("kit_dev/HelloWorld", { + itBundled("bake_dev/HelloWorld", { todo: true, files: { "/a.js": `console.log("Hello, world!")`, }, - format: "internal_kit_dev", + format: "internal_bake_dev", target: "bun", run: { stdout: "Hello, world!" }, onAfterBundle(api) { @@ -16,17 +16,17 @@ describe("bundler", async () => { api.expectFile("out.js").toContain("importSync"); }, }); - itBundled("kit_dev/SimpleCommonJS", { + itBundled("bake_dev/SimpleCommonJS", { todo: true, files: { "/a.js": `console.log(require('./b').message)`, "/b.js": `module.exports = { message: "Hello, world!" }`, }, - format: "internal_kit_dev", + format: "internal_bake_dev", target: "bun", run: { stdout: "Hello, world!" }, }); - itBundled("kit_dev/SimpleESM", { + itBundled("bake_dev/SimpleESM", { todo: true, files: { "/a.js": ` @@ -35,7 +35,7 @@ describe("bundler", async () => { `, "/b.js": `export default "Hello, world!"`, }, - format: "internal_kit_dev", + format: "internal_bake_dev", target: "bun", run: { stdout: "Hello, world!" }, }); diff --git a/test/bundler/expectBundled.ts b/test/bundler/expectBundled.ts index 3805133e85..79f86edb32 100644 --- a/test/bundler/expectBundled.ts +++ b/test/bundler/expectBundled.ts @@ -162,7 +162,7 @@ export interface BundlerTestInput { /** Defaults to "bundle" */ packages?: "bundle" | "external"; /** Defaults to "esm" */ - format?: "esm" | "cjs" | "iife" | "internal_kit_dev"; + format?: "esm" | "cjs" | "iife" | "internal_bake_dev"; globalName?: string; ignoreDCEAnnotations?: boolean; emitDCEAnnotations?: boolean;