Skip to content

build: Bundle vats with vite #742

@grypez

Description

@grypez

Task

  • Switch vat code bundling from @endo/bundle-source to vite+rollup

Background

Bundling Entrypoints with Endoify

It is mission critical that the ocap-kernel code runs in a locked down environment. We rely upon the endoify shim to perform lockdown, which reduces the requirement to one simple constraint: Every ocap kernel production entrypoint MUST begin by importing the endoify shim.

We use @endo/bundle-source in @metamask/kernel-shims to bundle ses and other @endo dependencies coherently. We don't need to endoify vat bundles because they aren't entry points. Vat bundles are loaded by the vat supervisor inside an endoified environment. In the browser runtime, entrypoints are endoified using our vite plugins jsTrustedPrelude and htmlTrustedPrelude. In the nodejs runtime, the vat-worker entrypoint is endoified via a first line import of the endoify shim.

Liveslots

The ocap kernel relies upon @agoric/swingset-liveslots to implement the machinery in the vats innards that makes it go. The makeLiveSlots function requires buildVatNamespace returns a promise for an object with a buildRootObject method. We currently transform a vat bundle into such an object using @endo/import-bundle. The unbundling strategy here must be compatible with the bundling strategy.

Requirements

  • The shims in @metamask/kernel-shims are still bundled with @endo/bundle-source
  • Bundling with yarn ocap bundle uses vite
  • The vats in @ocap/kernel-test are bundled with vite
  • @endo/bundle-source appears as a dev dependency of @metamask/kernel-shims
  • @endo/bundle-source is not a dependency of any other package in the monorepo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions