Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bake: csr, streaming ssr, serve integration, safer jsvalue functions, &more #14900

Merged
merged 48 commits into from
Nov 14, 2024

Conversation

paperclover
Copy link
Member

@paperclover paperclover commented Oct 29, 2024

What does this PR do?

Despite the expectHugeBreakingChanges warning gone, this API is still under revision and will recieve more huge breaking changes. To use DevServer past this commit, use export default

export default {
    port: 3000,
    fetch(request, server) {
        return new Response("my existing backend");
    },
    
    app: {
        framework: 'react',
    }
}

@robobun
Copy link

robobun commented Oct 29, 2024

@paperdave, your commit 2467e2e has 2 failures in #6069:

  • test/cli/run/require-cache.test.ts - 1 failing on 🪟 x64
  • test/js/bun/http/serve.test.ts - 1 failing on 🍎 aarch64
  • test/js/bun/http/serve.test.ts - 1 failing on 🍎 aarch64
  • @paperclover paperclover marked this pull request as draft October 29, 2024 23:58
    @paperclover paperclover changed the title bake: client-side navigation, zig jsvalue changes, new devserver api bake: csr, streaming ssr, serve integration, safer jsvalue functions, &more Oct 30, 2024
    src/deps/uws.zig Outdated Show resolved Hide resolved
    bun.Output.errGeneric("Cannot use client-side --target={s} with --server-components", .{@tagName(target)});
    Global.crash();
    }
    if (bun.FeatureFlags.bake and args.flag("--server-components")) {
    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    no more comptime? it's just a few branches but we can easily eliminate them with the enclosing comptime FeatureFlags.bake

    Copy link
    Member Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    bun.FeatureFlags.bake is a compile time variable. i know this because it is a const defined outside of a function. Zig has a semantic guarantee to inline and eliminate this branch, so this is zero branches for the same logic, and presented more concisely. i know this guarantee is always going to hold true because if it did not, many places in the codebase would fail to compile.

    additionally, i wrote this code before the version of this was added on main.

    config.deinit();
    return e;
    };

    if (globalObject.hasException()) {
    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    can we delete this check? does the error thrown from ServerType.init cover it?

    Copy link
    Member Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    no 😭

    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    i will audit locations like this soon in my project

    @@ -2501,7 +2501,7 @@ pub const Arguments = struct {
    arguments.eat();

    if (val.isObject()) {
    if (val.getOptional(ctx, "recursive", bool) catch {
    if (val.getBooleanStrict(ctx.ptr(), "recursive") catch {
    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    lol

    };

    for (options.framework.file_system_router_types, 0..) |fsr, i| {
    const joined_root = bun.path.joinAbs(cwd, .auto, fsr.root);
    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    the buffer used by joinAbs is guaranteed to not be used by readDirInfoIgnoreError?

    @@ -123,6 +225,12 @@ pub const Framework = struct {
    // f.resolveHelper(client, &sc.client_runtime_import, &had_errors);
    }

    for (clone.file_system_router_types) |*fsr| {
    fsr.root = bun.path.joinAbs(server.fs.top_level_dir, .auto, fsr.root);
    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    The use of this shared buffer is a little suspicious to me

    var i_2: usize = 0;
    const extensions = try arena.alloc([]const u8, len);
    while (it_2.next()) |array_item| : (i_2 += 1) {
    extensions[i_2] = refs.track(try array_item.toSlice2(global, arena));
    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Do you think it would be worth checking if any of the strings in the array are *, like the isString() case above?

    Copy link
    Member Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    yes

    src/bake/bake.zig Outdated Show resolved Hide resolved
    src/bun.js/api/server.zig Outdated Show resolved Hide resolved
    @dylan-conway dylan-conway merged commit 32ddf34 into main Nov 14, 2024
    9 of 14 checks passed
    @dylan-conway dylan-conway deleted the dave/more-bake branch November 14, 2024 02:19
    snoglobe pushed a commit that referenced this pull request Nov 18, 2024
    snoglobe pushed a commit that referenced this pull request Nov 21, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    5 participants