This commit is contained in:
Alistair Smith
2025-09-08 17:57:52 -07:00
parent 3e747886aa
commit ba5e4784aa
4 changed files with 32 additions and 13 deletions

View File

@@ -712,6 +712,9 @@ fn addInternalImports(b: *Build, mod: *Module, opts: *BunBuildOptions) void {
.{ .file = "bake.client.js", .import = "bake-codegen/bake.client.js", .enable = opts.shouldEmbedCode() },
.{ .file = "bake.error.js", .import = "bake-codegen/bake.error.js", .enable = opts.shouldEmbedCode() },
.{ .file = "bake.server.js", .import = "bake-codegen/bake.server.js", .enable = opts.shouldEmbedCode() },
.{ .file = "bun-framework-react/client.tsx", .enable = opts.shouldEmbedCode() },
.{ .file = "bun-framework-react/server.tsx", .enable = opts.shouldEmbedCode() },
.{ .file = "bun-framework-react/ssr.tsx", .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() },

View File

@@ -363,6 +363,29 @@ list(APPEND BUN_BAKE_RUNTIME_CODEGEN_SOURCES
set(BUN_BAKE_RUNTIME_OUTPUTS
${CODEGEN_PATH}/bake.client.js
${CODEGEN_PATH}/bake.server.js
${CODEGEN_PATH}/bun-framework-react/.copied
)
# Copy entire bun-framework-react package to codegen directory
add_custom_command(
OUTPUT
${CODEGEN_PATH}/bun-framework-react/.copied
COMMAND
${CMAKE_COMMAND} -E remove_directory ${CODEGEN_PATH}/bun-framework-react
COMMAND
${CMAKE_COMMAND} -E copy_directory ${CWD}/packages/bun-framework-react ${CODEGEN_PATH}/bun-framework-react
COMMAND
${CMAKE_COMMAND} -E touch ${CODEGEN_PATH}/bun-framework-react/.copied
DEPENDS
${CWD}/packages/bun-framework-react/client.tsx
${CWD}/packages/bun-framework-react/server.tsx
${CWD}/packages/bun-framework-react/ssr.tsx
${CWD}/packages/bun-framework-react/index.ts
${CWD}/packages/bun-framework-react/bake.private.d.ts
${CWD}/packages/bun-framework-react/package.json
${CWD}/packages/bun-framework-react/tsconfig.json
COMMENT
"Copying bun-framework-react package to codegen"
)
register_command(

View File

@@ -405,8 +405,6 @@ async function readCssMetadata(stream: ReadableStream<Uint8Array<ArrayBuffer>>)
location.reload();
}
}
DEBUG.ASSERT(header !== undefined);
DEBUG.ASSERT(header[0] !== undefined);
if (header[0] > 0) {
const cssRaw = (await reader.read(new Uint8Array(header[0]))).value;
if (!cssRaw) {
@@ -470,8 +468,6 @@ async function readCssMetadataFallback(stream: ReadableStream<Uint8Array<ArrayBu
i += len;
size -= len;
}
DEBUG.ASSERT(chunk);
DEBUG.ASSERT(len !== undefined);
if (chunk.byteLength > len) {
chunks.unshift(chunk.subarray(len));
}
@@ -483,7 +479,6 @@ async function readCssMetadataFallback(stream: ReadableStream<Uint8Array<ArrayBu
if (header === 0) {
currentCssList = [];
} else {
DEBUG.ASSERT(header !== undefined);
currentCssList = td.decode(await readChunk(header)).split("\n");
}
if (chunks.length === 0) {

View File

@@ -282,20 +282,18 @@ pub const Framework = struct {
"bun-framework-react/server.tsx",
"bun-framework-react/ssr.tsx",
}, if (Environment.codegen_embed) &.{
.{ .code = @embedFile(bakeRelativePath ++ "/client.tsx") },
.{ .code = @embedFile(bakeRelativePath ++ "/server.tsx") },
.{ .code = @embedFile(bakeRelativePath ++ "/ssr.tsx") },
.{ .code = @embedFile("bun-framework-react/client.tsx") },
.{ .code = @embedFile("bun-framework-react/server.tsx") },
.{ .code = @embedFile("bun-framework-react/ssr.tsx") },
} else &.{
// Cannot use .import because resolution must happen from the user's POV
.{ .code = bun.runtimeEmbedFile(.src, bakeRelativePath ++ "/client.tsx") },
.{ .code = bun.runtimeEmbedFile(.src, bakeRelativePath ++ "/server.tsx") },
.{ .code = bun.runtimeEmbedFile(.src, bakeRelativePath ++ "/ssr.tsx") },
.{ .code = bun.runtimeEmbedFile(.src, "../packages/bun-framework-react/client.tsx") },
.{ .code = bun.runtimeEmbedFile(.src, "../packages/bun-framework-react/server.tsx") },
.{ .code = bun.runtimeEmbedFile(.src, "../packages/bun-framework-react/ssr.tsx") },
}) catch bun.outOfMemory(),
};
}
const bakeRelativePath = "../packages/bun-framework-react";
/// Default that requires no packages or configuration.
/// - If `react-refresh` is installed, enable react fast refresh with it.
/// - Otherwise, if `react` is installed, use a bundled copy of