-
Notifications
You must be signed in to change notification settings - Fork 5k
Confine bake's bundler, server, and CLI integration to designated seams #32078
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
Open
alii
wants to merge
35
commits into
main
Choose a base branch
from
ali/decouple-bake-3-seams
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
d3e954f
bake-decouple: fold CLI import.meta defines into one bake entry point
alii 52b0d70
bake-decouple: project LinkerContext.framework to plain bool facts
alii c7a2bd8
bake-decouple: move serve dev-server option building into bake
alii 910cdce
bake-decouple: move InternalBakeDev stmt transform into bake via hook
alii c86ee34
bake-decouple: collapse BuiltInModule conversion in resolver options …
alii 09e0ee9
bake-decouple: use canonical BuiltInModule in ParseTask, drop stale n…
alii db969ef
bake-decouple: erase bake types from server_body plugin/router seams
alii f0acede
bake-decouple: move production pipeline into bake, extract bake_types…
alii b394c1a
bake-decouple: move Bun.serve dev-server glue from server/mod.rs into…
alii d2da829
bake-decouple: move Target::bake_graph mapping into the bake_types seam
alii 1f2c482
bake-decouple: move dev server asset URL prefix to bun_options_types
alii 2c34c4a
bake-decouple: type-erase dev-server options out of ServerConfig
alii ad0af03
bake-decouple: own Framework view in options; drop bake_types shim
alii ab91c7c
bake-decouple: project router storage types, mark remaining bake edges
alii 711b11b
bake-decouple: supply manifest virtual-module names via BakeOptions
alii 5b029b3
bake-decouple: type-erase the dev_server slot out of server/mod.rs
alii 30b2f86
bake-decouple: rename BundlerOptions bake fields to CLI-flag names
alii 0d6f9f7
bake-decouple: move AnyRequestContext dev-server views into bake
alii a855301
bake-decouple: make HTMLBundle dev_server_id an opaque host token
alii 29272a3
bake-decouple: serve HMR runtime bytes to bundler via bake link hook
alii 04570ff
bake-decouple: move bake feature-flag gates out of bun_core into bake
alii 5e8bbbd
bake-decouple: project LinkerContext dev_server to a plain bool fact
alii 249382f
bake-decouple: move serve 'app' option read+gating into bake hook
alii 0ae91f7
bake-decouple: drop RequestContext's typed dev_server accessor
alii 8602fd9
bake-decouple: move FrameworkFileSystemRouter class def into bake
alii 3075b8a
bake-decouple: erase bake refs from server_body request/devtools paths
alii de6f23f
bake-decouple: make BundleV2 speak Target through the dev-server seam
alii 6836bf2
bake-decouple: rename allow_bake_config to allow_dev_server_options
alii 01dd6f4
bake-decouple: rustfmt fixups for fmt-violating sibling hunks
alii d9589a2
[autofix.ci] apply automated fixes
autofix-ci[bot] 6562aa6
bake-decouple: per-block SAFETY comments on the slot vtable bodies
robobun ea15091
ci: retrigger
robobun c473c31
bake-decouple: fix stale bridge comment referencing config.bake
robobun a110d44
bake-decouple: carry thiserror refactor to the moved/new seam code
robobun 4fcaa48
bake-decouple: re-open the bundler pipeline surface the extracted dri…
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| //! CYCLEBREAK(b0) TYPE_ONLY seam module: pure value types shared between the | ||
| //! bundler internals and `bun_runtime::bake`, kept at the lower tier so the | ||
| //! bundler can consume them without depending on the full DevServer. | ||
| //! `bun_runtime::bake` re-exports these as the canonical defs and constructs | ||
| //! values of them (e.g. `Framework` is projected from the runtime-side | ||
| //! superset via `as_bundler_view`). | ||
|
|
||
| #[repr(u8)] | ||
| #[derive(Copy, Clone, Eq, PartialEq, Debug, core::marker::ConstParamTy)] | ||
| pub enum Side { | ||
| Client = 0, | ||
| Server = 1, | ||
| } | ||
| #[repr(u8)] | ||
| #[derive(Copy, Clone, Eq, PartialEq, Debug)] | ||
| pub enum Graph { | ||
| Client = 0, | ||
| Server = 1, | ||
| Ssr = 2, | ||
| } | ||
| /// Used for the per-file `// path (target)` comment | ||
| /// in postProcessJSChunk and friends. | ||
| impl From<Graph> for &'static str { | ||
| fn from(g: Graph) -> Self { | ||
| match g { | ||
| Graph::Client => "client", | ||
| Graph::Server => "server", | ||
| Graph::Ssr => "ssr", | ||
| } | ||
| } | ||
| } | ||
| impl Side { | ||
| pub fn graph(self) -> Graph { | ||
| match self { | ||
| Side::Client => Graph::Client, | ||
| Side::Server => Graph::Server, | ||
| } | ||
| } | ||
| } | ||
| /// Bundler-only `Target` extension: which dev-server graph a file bundled for | ||
| /// that target lands in. Declared next to `Graph` because the canonical | ||
| /// `Target` lives in `bun_ast` (lower tier, cannot name seam types); callers | ||
| /// import it from here (`crate::bake_types::TargetExt`). | ||
| pub trait TargetExt: Copy { | ||
| fn bake_graph(self) -> Graph; | ||
| } | ||
| impl TargetExt for bun_ast::Target { | ||
| fn bake_graph(self) -> Graph { | ||
| use bun_ast::Target; | ||
| match self { | ||
| Target::Browser => Graph::Client, | ||
| Target::ServerComponentsSsr => Graph::Ssr, | ||
| Target::BunMacro | Target::Bun | Target::Node => Graph::Server, | ||
| } | ||
| } | ||
| } | ||
| /// Canonical definition lives in `bun_options_types` (T3); re-exported | ||
| /// here so bundler and bake (in runtime, T6) share one nominal type. | ||
| pub use bun_options_types::BuiltInModule; | ||
|
|
||
| /// Bundler-owned TYPE_ONLY `Framework` view — canonical defs live in | ||
| /// `options_impl` (they are made of bundler/parser vocabulary, no bake | ||
| /// references); re-exported here so `bun_runtime::bake` keeps reaching them | ||
| /// through the seam module when projecting its canonical `bake.Framework` | ||
| /// via `as_bundler_view`. | ||
| pub use crate::options_impl::{Framework, ReactFastRefresh, ServerComponents}; | ||
|
|
||
| /// Seam type: the HMR runtime preamble the linker splices ahead of each | ||
| /// `Format::InternalBakeDev` chunk. | ||
| #[derive(Clone, Copy)] | ||
| pub struct HmrRuntime { | ||
| pub code: &'static [u8], | ||
| } | ||
| /// Alias used at the crate root (`crate::HmrRuntimeSide`); identical to `Side`. | ||
| pub(crate) type HmrRuntimeSide = Side; | ||
|
|
||
| /// The runtime's bytes are embedded once, by `bun_runtime`'s dev-server module | ||
| /// (which also hands them to JSC); the bundler reaches them through the | ||
| /// link-time hook below, same pattern as `__bun_bake_convert_stmts_for_chunk_hmr` | ||
| /// in `lib.rs`. Memoized per side. | ||
| pub(crate) fn get_hmr_runtime(side: Side) -> HmrRuntime { | ||
| static CLIENT: std::sync::OnceLock<HmrRuntime> = std::sync::OnceLock::new(); | ||
| static SERVER: std::sync::OnceLock<HmrRuntime> = std::sync::OnceLock::new(); | ||
| let cell = match side { | ||
| Side::Client => &CLIENT, | ||
| Side::Server => &SERVER, | ||
| }; | ||
| *cell.get_or_init(|| __bun_bake_get_hmr_runtime(side)) | ||
| } | ||
|
|
||
| unsafe extern "Rust" { | ||
| /// Defined `#[no_mangle]` in `bun_runtime` (`bake/bake_body.rs`). All | ||
| /// argument/return types are safe Rust values (no raw-pointer | ||
| /// preconditions), so the link-time-resolved body upholds Rust's | ||
| /// invariants on its own. | ||
| safe fn __bun_bake_get_hmr_runtime(side: Side) -> HmrRuntime; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.