-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 dev server tracking issue #14324
Comments
@paperdave I just discovered this tracking issue and am really excited about it! I also saw |
Great. I had spotted this package existing and I was a little worried on the difficulty of getting the package. I don't fully know what the plan will be, but I think the react project itself publishes the So far, I got server components to work using
on the server, i noticed that react sort of just ignores the manifest when using the browser build. when using the node.js server build, it uses dynamic so the bun version would basically work the same, but i would probably hold off doing it for a little bit longer in case some more bundler changes happen and there is a more optimal way to write the integration. |
was messing around with the state of things, mainly writing own framework code. my notes
|
on server functions, runtime type safety is tricky. const func = (name: string) => {
"use server";
console.log({ name }); // could be number
};
<button onClick={func}>Click</button>; why not create a hono/elysia-like rpc from fs routes located in import z from "zod";
export const POST = async ({ request }: { request: Request }) => {
z.object({ name: z.string() }).safeParse(await request.json());
}; this way you have better access to context, like the Request, and more runtime validation that is beyond just ts intellisense |
frameworks will likely be able to customize/implement the serialization and validation layer. while i haven't fully read the react rfcs and implementations, i think it a framework could provide zod integration via a wrapped function:
if the bundler just annotates the arrow function with a unique id (which is something that the framework can control), no guarentee on this thought though. wonder if we could even omit "use server" in this case and make the action entirely defined via |
i got some questions. where is the code that gets the error from zod and returns it stored? how do you consume that error? is the error typed? can you use something other than zod? |
these are all up to the decision of the framework; the underlying api/bundler doesn't care. |
css dev server related:
|
With #14258 merged, Bake can finally be tried out in canary builds (usage guide at end of issue). However, it is missing many features and testing that make it currently unsuitible for production-grade applications (See #14763).
Remember this list is not in order, and that not every item on this list is strictly a blocker. I will edit it as the plan changes.
Contributions are appreciated. Please join #bake in the Bun Discord for questions relating to the architecture of the Dev Server, as well as if you are trying it out as a user or framework author.
This should have a custom path that does not invoke the bundler.Waiting on Integrate CSS with bundler #14281"use server"
.minifySyntax
is not allowed as affects DCE in an observable way)Request
input (currently, theRequest
object given to the framework entry point is fake)Accept
header. Concrete use case: picking between serialized RSC payload or HTML.While the above two are not really dev-server features, it should be possible to enable them in DevServer mode by a flag.separateSSRGraph: false
POST /render
to render a non-route server component.*framework.serverEntryPoint
)Bun.wipDevServerExpectHugeBreakingChanges
to an integration inBun.serve
Bun.serve
is subpar, contains too much code, and users deserves a redesigned modal. (partially contributor friendly)DevServer
. Must not interfere with the ability to use the web-app "offline"bun install
is run and reload the specific node_modules folders it changes.*cmd+s
is too much text imo.client-only
andserver-only
packages as special-cased errors.*bun build --watch
but no one has noticed???TODO: Repair live bindings
Left unimplementedTODO: check if this local is immediately assigned require() if so, we will instrument it with hot module reloading.
module.hot
(webpack)import.meta.hot
(vite)IncrementalGraph
and rebuild direct dependents. In turn, that should place a directory watcher for when the file is restored.Cmd+R
is pressed, it must not serve a stale bundle. The design for this to be fast is already present, but bundle re-assembly is not yet implemented.<a>
tags. (contributor friendly)react-server-dom-webpack
, getreact-server-dom-bun
Consider restoring the separate bundler thread if server code evaluation is blocking too long. I have noticed that spamming HMR events makesWould be bad. Instead, make bundling asyncronous. This will fix a crash.DevServer
lag behind. This is either due to VSCode buffering saves together, or the spam of the event loop causes websocket backpressure. I have not fully explored the options, but it is worth investigating if the bundling could be done on the watcher thread. If not, then a third thread is used. A mutex would be needed for the client-side asset files, but not for the server side code.import.meta.env
defines that we miss to match vite (contributor friendly)__webpack_require__
polyfill (get react-server-dom-bun)Bun
global. This restriction is being imposed so thatbun build --compile
can one day generate much smaller production binaries (e.g. someone not usingBun.build
/Bun.Transpiler
in their app can drop the entire bundler from the binary). Since Bake is new, we can add this restriction here but not in the runtime, and it is not a breaking change.Expr.Data.writeToHasher
is incomplete (contributor friendly)generation for 'bun:bake/client'
hot-module-reloading instrumentation for 'export { ... } from'
hot-module-reloading instrumentation for 'export * from'
not supportingnon-framework provided entry-point
support non-server components build
*handle listen failure
I will update this as I think of more. These are just the steps that come to mind. Additionally, I will open another issue containing the plan for production builds, though I think some of this work waits on the API design.
*does not block releasing 1.2 imo
Reliability
There are currently 3 unit tests in total for Bake. Given the size and scope of the dev server alone, much more testing and tooling is needed.
./test/bundler
--format=internal_kit_dev
), initial payload--react-fast-refresh
)--server-components
)bake.DevServer.IncrementalGraph
. This is done using a wrapper over the dev server, using the WebSocket protocol to bind custom actions.Performance
While I have done little testing on the performance, I am confident that large projects will show decent reloading speed, but there is significant cost placed on the first bundle task. I'm sure a lot of work can be done to profile and micro-optimize things, but here is a list of broader changes to the design:
Earlier stated idea about revivingDecided to not do.BundleThread
IncrementalGraph
garbage collection (1) at all, (2) while a browser tab is focused and source files are unlikely to be savedIncrementalGraph
to disk, so that closing and re-opening the dev server does not have to rebundle anything. Care must be taken to not be vulnerable to cache poisoning. This might not compelling, especially on smaller projects where the total time to build all files is under a second. I am only listing this point because I realized it was easy to write.Open-ended performance tasks:
Informal Usage Guide
TODO: the usage guide is out of date and has been removed
The text was updated successfully, but these errors were encountered: