BakeNative is under active development. APIs may change.
Skip to Content
BakeNative

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.

PackageContents (bin/)Installed
@bake-native/react, @bake-native/octaneReact or Octane adapter and the bake CLI entrythe app selects one
@bake-native/coreShared CLI implementation, runtime JS, styles, types, compat.jsonthrough the selected adapter
@bake-native/toolchain-darwin-arm64hermesc, bake-css-lint, bake-frame, bake-snap (macOS, Apple silicon), and in apple/ the Apple runtime: BakeNative.xcframework.zip with runtime.jsonas an optional dependency of @bake-native/core, only on a matching os / cpu
@bake-native/toolchain-darwin-x64hermesc, bake-css-lint (macOS, Intel)〃
@bake-native/toolchain-linux-x64hermesc, bake-css-lint (Linux x64, glibc)〃
@bake-native/toolchain-win32-x64hermesc.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:

Toolbake runs it forVariable
hermescapp.hbc of every native targetBAKE_HERMESC (or --hermesc)
bake-css-lintthe native build gate: every native target's CSS, markup and first commitBAKE_CSS_LINT
bake-framebake build --bake (the first-screen snapshot app.baked)BAKE_FRAME
bake-snapbake 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 (the ios/build.sh and macos/build.sh of an app from bake create run it) unpacks the archive to <app>/.bake/native/bakenative, a Swift package named BakeNative with the products BakeNativeKit and BakeNativeAppKit over 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) or Package.swift and the generated BakeNativeAppModules package (.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, not node_modules.

  • It fails closed. bake native link refuses a runtime whose package or runtime.json names another @bake-native/core version, runtime, host protocol, Hermes bytecode or schema digest, and an archive that is not the one runtime.json names, 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.2

    The 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:

FieldMeaningKept equal to
@bake-native/coreThe npm versionpackage.json, every @bake-native/toolchain-* package, what each Rust tool reports (<tool> --version, compiled in from this file)
runtime.version, runtime.seriesThe runtime this release builds for (the ABI series is 0.<minor> before 1.0)Swift BakeNativeRuntime.version
hostProtocolThe newest host command protocol the runtime understandsRust Bundle::SUPPORTED_HOST_PROTOCOL, Swift BakeNativeBundle.supportedHostProtocol
hermes.commit, hermes.bytecodeThe Hermes commit and the HBC bytecode version it emitstools/build-hermes/Plugins/BuildHermes/plugin.swift's pin
schemaDigestThe core / host ABI schemaHOST_SCHEMA_DIGEST in fingerprint.mjs, the generated Rust host_abi.rs
batchDigestThe renderer batch stream a bundle writes and bake-frame readsBATCH_DIGEST in batch-wire.js, the generated Rust batch_wire.rs
octaneThe Octane version the compiler integration and renderer targetthe pnpm catalog
toolchain<platform>-<arch> → its package, its tools, the libraries they load and, for darwin-arm64, the apple runtime filesoptionalDependencies, 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, and bake-frame with --bake) does not answer --version, or was built for another @bake-native/core version, host schema digest or batch digest
  • the installed @bake-native/core files carry another version's table (a mixed install)
  • the app's octane is 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

  1. 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 (fixed in .changeset/config.json). Do not put issue-tracker ids in changesets: the changelog is public.
  2. After the change merges to main, the release workflow opens or updates the Version Packages pull request (pnpm version-packages: changeset version, then tools/release/version.mjs moves compat.json and the Swift runtime version with it).
  3. Run Release Screens and approve its npm stage if the version of @bake-native/screens in packages/screens/package.json is new. Mobile projects created by bake create install that version. The BakeNative workflow checks it is available before staging @bake-native/core.
  4. 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 where bake-frame / bake-snap need 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 for hermesc.exe / bake-css-lint.exe and every VC++ runtime DLL a binary imports shipped beside it, hermesc -version, a test compile and every tool's --version on the runner that can run them; the Apple runtime's runtime.json equal 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 pack and checked (no workspace: or catalog: range left, a LICENSE, the dist built, a toolchain tarball's bin/ and apple/ equal to the table, and every tool of a macOS or Linux package executable in the tarball: pnpm pack keeps that bit only for the files publishConfig.executableFiles names), then staged with npm stage publish --provenance (tools/release/publish.mjs --stage)
    • a draft GitHub release vX.Y.Z is created with the changelog section and the tarballs
  5. Approve the staged versions on npmjs.com, or with npm stage list <package> and npm 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.

On this page