Releasing to npm
How @bake-native/core and its toolchain packages are versioned, checked against the version table, and released with Changesets and npm trusted publishing.
In a published release, installing either renderer pulls in @bake-native/core, which supplies the bake CLI, the runtime JS, controls.css and the types, plus
one prebuilt toolchain for the machine it runs on: the Hermes compiler and the Rust tools bake
runs, and on a Mac with Apple silicon the prebuilt Apple runtime iOS and macOS apps link. No
Cargo, Hermes build or source checkout is needed.
| Package | Contents (bin/) | Installed |
|---|---|---|
@bake-native/react, @bake-native/octane | React or Octane adapter and the bake CLI entry | the app selects one |
@bake-native/core | Shared CLI implementation, runtime JS, styles, types, compat.json | through the selected adapter |
@bake-native/toolchain-darwin-arm64 | hermesc, bake-css-lint, bake-frame, bake-snap (macOS, Apple silicon), and in apple/ the Apple runtime: BakeNative.xcframework.zip with runtime.json | as an optional dependency of @bake-native/core, only on a matching os / cpu |
@bake-native/toolchain-darwin-x64 | hermesc, bake-css-lint (macOS, Intel) | 〃 |
@bake-native/toolchain-linux-x64 | hermesc, bake-css-lint (Linux x64, glibc) | 〃 |
@bake-native/toolchain-win32-x64 | hermesc.exe, bake-css-lint.exe (static CRT), bake-frame.exe, and bakenative-app.exe (the example Windows host bake dev --target windows opens the app in) with hermesvm.dll, bakenative_hermes.dll and the VC++ runtime DLLs beside them | 〃 |
The tools:
| Tool | bake runs it for | Variable |
|---|---|---|
hermesc | app.hbc of every native target | BAKE_HERMESC (or --hermesc) |
bake-css-lint | the native build gate: every native target's CSS, markup and first commit | BAKE_CSS_LINT |
bake-frame | bake build --bake (the first-screen snapshot app.baked) | BAKE_FRAME |
bake-snap | bake snap (CoreText snapshots, macOS) | BAKE_SNAP |
The Apple silicon toolchain includes bake-frame and bake-snap. The Windows x64 toolchain
includes bake-frame. On Intel Mac and Linux x64, a native build in Strong Mode requires
BAKE_FRAME to point to a matching snapshot baker. For an unbaked Android bundle, set
compiler.strong to false and build with baking disabled. Each host has one package that
contains its tools for the release.
bake takes each tool from its variable, then from the installed toolchain package, then (only
inside a BakeNative source checkout) builds the Rust tools with Cargo and takes hermesc from
native/hermes/artifacts. In a checkout the workspace's own packages/toolchain-* directory is
release staging and is skipped for the Rust tools. Without any of these the build fails with the
cause and the fix, e.g.:
✗ windows 0 ms
error: bake-css-lint is not available: @bake-native/toolchain-win32-x64@0.0.1 is not installed: @bake-native/core brings it as an optional dependency, which --no-optional / --omit=optional or a lockfile made on another platform leaves out. Reinstall @bake-native/core with optional dependencies (npm install --include=optional), or set BAKE_CSS_LINT to the path of bake-css-lint.exe built from the same BakeNative release. …@bake-native/testing and every example and test package are private and never released.
The Apple runtime
iOS and macOS apps link BakeNative.xcframework: BakeNativeKit for iOS and the iOS simulator and
BakeNativeAppKit for macOS (Apple silicon), each one Swift module with the Rust core and Hermes
linked in (tools/build-xcframework). It ships inside @bake-native/toolchain-darwin-arm64, as
apple/BakeNative.xcframework.zip next to apple/runtime.json, which says what it was built for
(the version table's @bake-native/core, runtime, host protocol, Hermes, schema digests), the
archive's SHA-256 and its slices. It is an archive because a macOS framework is made of symlinks,
which an npm tarball does not carry.
Apps use it through SwiftPM's local packages only. There is no remote binary target and no
Swift package registry: nothing is downloaded when Xcode or swift build resolves packages.
-
bake native link --target ios|mac(theios/build.shandmacos/build.shof an app frombake createrun it) unpacks the archive to<app>/.bake/native/bakenative, a Swift package namedBakeNativewith the productsBakeNativeKitandBakeNativeAppKitover one local.binaryTarget(path:). The same archive is not unpacked twice, so the host does not rebuild. -
The app's Xcode project (
ios/project.yml) orPackage.swiftand the generatedBakeNativeAppModulespackage (.bake/native/<target>) depend on that path. A package manager keeps the installed package under a path with its version in it (pnpm), so the app names its own copy, notnode_modules. -
It fails closed.
bake native linkrefuses a runtime whose package orruntime.jsonnames another@bake-native/coreversion, runtime, host protocol, Hermes bytecode or schema digest, and an archive that is not the oneruntime.jsonnames, with what differs, before it writes anything:error: the Apple runtime in …/@bake-native/toolchain-darwin-arm64/apple does not match @bake-native/core 0.0.2's version table (@bake-native/core/compat.json): it comes from @bake-native/toolchain-darwin-arm64 0.0.1, but @bake-native/core is 0.0.2: the two are released together. Install @bake-native/toolchain-darwin-arm64@0.0.2. it was built for @bake-native/core 0.0.1, not 0.0.2The runtime checks the bundle again when it loads it (its runtime series, host protocol and bytecode version).
The prebuilt runtime has the two hosts and nothing else of the BakeNative Swift package. A bundle
that uses a first-party module the app has no copy of (bake add gives it one), or a native view
(<video> included: its glue compiles against the core's headers), is refused by
bake native link with that reason; build those against a source checkout
(bake native link --bakenative <checkout>). --bakenative, and a bake that runs from a checkout,
always use the checkout's Swift package.
The version table
packages/core/compat.json is the one place that says which versions belong together:
| Field | Meaning | Kept equal to |
|---|---|---|
@bake-native/core | The npm version | package.json, every @bake-native/toolchain-* package, what each Rust tool reports (<tool> --version, compiled in from this file) |
runtime.version, runtime.series | The runtime this release builds for (the ABI series is 0.<minor> before 1.0) | Swift BakeNativeRuntime.version |
hostProtocol | The newest host command protocol the runtime understands | Rust Bundle::SUPPORTED_HOST_PROTOCOL, Swift BakeNativeBundle.supportedHostProtocol |
hermes.commit, hermes.bytecode | The Hermes commit and the HBC bytecode version it emits | tools/build-hermes/Plugins/BuildHermes/plugin.swift's pin |
schemaDigest | The core / host ABI schema | HOST_SCHEMA_DIGEST in fingerprint.mjs, the generated Rust host_abi.rs |
batchDigest | The renderer batch stream a bundle writes and bake-frame reads | BATCH_DIGEST in batch-wire.js, the generated Rust batch_wire.rs |
octane | The Octane version the compiler integration and renderer target | the pnpm catalog |
toolchain | <platform>-<arch> → its package, its tools, the libraries they load and, for darwin-arm64, the apple runtime files | optionalDependencies, each package's os / cpu / files, a cargo binary per Rust tool |
tools/check-versions.mjs (part of pnpm check) fails when any of these disagree.
bake build checks the toolchain against the table before it writes a bundle, and fails with
the reason:
- the hermesc does not emit the table's bytecode version (
hermesc -version), or does not say - the hermesc comes from an
@bake-native/toolchain-*package of another version - a Rust tool (
bake-css-lint, andbake-framewith--bake) does not answer--version, or was built for another @bake-native/core version, host schema digest or batch digest - the installed
@bake-native/corefiles carry another version's table (a mixed install) - the app's
octaneis not the table's - the bundle would declare a host protocol newer than the runtime understands
bake native link checks the Apple runtime the same way before it unpacks it.
The compiled app.hbc header is checked again after hermesc runs.
✗ windows 0 ms
error: toolchain does not match @bake-native/core 0.0.2's version table (@bake-native/core/compat.json):
hermesc /opt/hermes/hermesc emits Hermes bytecode v96; runtime 0.0.2 runs only v100, so the app would refuse app.hbc. …Making a release
- With a user-visible change, add a changeset:
pnpm changeset, pick@bake-native/core, the bump, and one line for the changelog. Both renderer packages and all four toolchain packages take@bake-native/core's version (fixedin.changeset/config.json). Do not put issue-tracker ids in changesets: the changelog is public. - After the change merges to
main, thereleaseworkflow opens or updates the Version Packages pull request (pnpm version-packages:changeset version, thentools/release/version.mjsmovescompat.jsonand the Swift runtime version with it). - Run Release Screens and approve its npm stage if the version of
@bake-native/screensinpackages/screens/package.jsonis new. Mobile projects created bybake createinstall that version. The BakeNative workflow checks it is available before staging@bake-native/core. - Merging the version pull request releases BakeNative:
- each host's toolchain is built on its own runner (macOS arm64 and x64, Ubuntu 22.04,
Windows): hermesc from the pinned Hermes commit (
tools/build-hermes/hermesc.mjs), the Hermes VM wherebake-frame/bake-snapneed it, and the Rust tools (tools/release/build-toolchain.mjs); on macOS arm64 also the Apple runtime, with Hermes and the Rust core built for iOS, the iOS simulator and macOS (tools/release/build-apple-runtime.mjs); then it is staged into its package and checked (tools/release/stage-toolchain.mjs: exactly the table's files, binary format and CPU, a static CRT forhermesc.exe/bake-css-lint.exeand every VC++ runtime DLL a binary imports shipped beside it,hermesc -version, a test compile and every tool's--versionon the runner that can run them; the Apple runtime'sruntime.jsonequal to the table, the archive's SHA-256, and every slice's framework an arm64 Mach-O library of this version with its.swiftinterface) - every public package is packed with
pnpm packand checked (noworkspace:orcatalog:range left, aLICENSE, the dist built, a toolchain tarball'sbin/andapple/equal to the table, and every tool of a macOS or Linux package executable in the tarball:pnpm packkeeps that bit only for the filespublishConfig.executableFilesnames), then staged withnpm stage publish --provenance(tools/release/publish.mjs --stage) - a draft GitHub release
vX.Y.Zis created with the changelog section and the tarballs
- each host's toolchain is built on its own runner (macOS arm64 and x64, Ubuntu 22.04,
Windows): hermesc from the pinned Hermes commit (
- Approve the staged versions on npmjs.com, or with
npm stage list <package>andnpm stage approve <id>for each package (toolchain packages first), then publish the draft GitHub release (this creates the tag).
workflow_dispatch on the release workflow runs step 3 as a dry run: everything is built,
packed and checked, and npm publish --dry-run runs instead of staging.
Locally: pnpm release:dry-run -- --only @bake-native/toolchain-<this host>,@bake-native/core after staging
this host's toolchain into one directory (node tools/build-hermes/hermesc.mjs --out <dir>,
node tools/release/build-toolchain.mjs --out <dir> with the Hermes VM built by pnpm hermes,
on a Mac with Apple silicon node tools/release/build-apple-runtime.mjs --out <dir> (it needs
the Rust targets aarch64-apple-ios and aarch64-apple-ios-sim; BAKE_XCFRAMEWORK_JOBS=1
builds one slice at a time), then node tools/release/stage-toolchain.mjs <key> <dir>). On
Windows run them from an MSVC environment; outside one, pass --crt <dir> with the VC++ runtime
DLLs. To try the result the way a user gets it, install the two tarballs from out/release into
an app outside the repository and run bake build with Cargo off PATH; on a Mac, also
pnpm build:ios and pnpm build:mac of an app from bake create, then build ios/ with Xcode
and macos/ with swift build.
Use full scoped package names, separated by commas, with --only. Use --screens for the separate screens staging path.
npm setup
The workflow authenticates with npm trusted publishing (OIDC): no npm token secret. Every
released package needs a trusted publisher on npmjs.com with repository gronxb/bake-native,
workflow release.yml, no environment, and npm stage publish allowed. The workflow needs
npm 12 (installed by the workflow) and Node 24.