Migrate JS/TS templates to @cartesi/rollup, pnpm and node 24 - #89
Open
tuler wants to merge 7 commits into
Open
Conversation
Replace the ROLLUP_HTTP_SERVER_URL polling loop of the JavaScript and TypeScript templates with the @cartesi/rollup package, which talks directly to the rollup device of the Cartesi Machine. The package is a native addon, so the runtime dependencies are now installed in a new riscv64 stage, where the matching prebuilt binary is selected, and the application code is bundled with the dependencies kept external. Both templates are ESM now, and the bundle is emitted as index.mjs. The TypeScript template no longer generates types from the rollup OpenAPI spec, since the package ships its own, dropping the schema.ts codegen and the openapi-fetch, openapi-typescript and viem dependencies. Its runtime stage was also missing the APT_UPDATE_SNAPSHOT argument, which made the apt snapshot pin empty. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YQk8hkw6zUJe38hM7LNd4r
Replace yarn with pnpm on the JavaScript and TypeScript templates. The version is pinned by the packageManager field of package.json and installed with corepack, which is bundled with the node images. The pnpm-workspace.yaml file allows the build scripts of @cartesi/rollup and esbuild, which pnpm blocks by default, and exempts @cartesi/rollup from the minimum release age, so that a freshly published pre-release can be installed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YQk8hkw6zUJe38hM7LNd4r
tuler
marked this pull request as draft
August 13, 2026 20:21
The esbuild command line grew past what is comfortable in a package.json script, so the options move to a build.js/build.ts file using the esbuild JavaScript API, which is also where an application is likely to extend them. The image entrypoint is now node itself. rollup-init only execs rollup-http-server, which bridges the rollup device to HTTP, and the application talks to the device directly through @cartesi/rollup. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YQk8hkw6zUJe38hM7LNd4r
The machine guest tools are installed in /usr/bin, and nothing else creates /opt/cartesi/bin, so the directory does not exist in the image. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YQk8hkw6zUJe38hM7LNd4r
The bundler options move from a build script to a rolldown.config file, read by the rolldown CLI, which is the configuration format of the bundler. esbuild is still installed on the TypeScript template as a dependency of tsx, but its install script is not needed, and is denied. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YQk8hkw6zUJe38hM7LNd4r
The template has no tests, and the JavaScript one does not carry a test runner either, so vitest goes away. typescript is bumped to 7, which type checks the template with the existing configuration, and tsx to its latest release. @types/node is bumped within the 22 line, the node version of the application image, so that the types describe the runtime the application actually runs on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YQk8hkw6zUJe38hM7LNd4r
Both the riscv64 base and the build stage move to node 24.17.0, and @types/node follows the same line on the TypeScript template. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YQk8hkw6zUJe38hM7LNd4r
Member
Author
|
We should wait for Cartesi CLI version with cartesi-machine 0.21 support, but this is pretty much ready for review. |
tuler
marked this pull request as ready for review
August 14, 2026 01:52
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Migrates the JavaScript and TypeScript templates from the rollup HTTP server to the
@cartesi/rolluppackage, which talks directly to the rollup device of the Cartesi Machine, and refreshes the toolchain around it.Key Changes
Source code
rollup.run(), whose handlers receive typed request objects:msgSender,index,blockTimestamp, andpayloadas aBufferboolean(trueaccepts the input,falserejects it) instead of a status string, and inspect handlers answer with reportsschema.tscodegen script is gone, along withopenapi-fetch,openapi-typescriptandviem, since the package ships its own typesdist/index.mjsDocker
nodeitself, withindex.mjsas the command.rollup-initonly execsrollup-http-server, which bridges the rollup device to HTTP, and the application now talks to the device directly@cartesi/rollupis a native addon, and its installation selects the prebuilt binary of the platform it runs on. The build stage still bundles the application code on the build platform, with the dependencies left externalROLLUP_HTTP_SERVER_URL, and dropped/opt/cartesi/binfromPATH, as the machine guest tools are installed in/usr/binToolchain
packageManagerfield ofpackage.jsonand installed with corepackpnpm-workspace.yaml, which allows the build script of@cartesi/rollupand exempts it from the minimum release age, so that a freshly published pre-release can be installed. The build script of esbuild, which comes in as a dependency of tsx, is denied, as tsx runs without itrolldown.config.jsandrolldown.config.tstsxin place ofts-node,tsconly type checks, and vitest is dropped, as the template has no testsDocumentation
CMT_INPUTS, with a pointer to@cartesi/codecfor encoding advance inputsNotable Implementation Details
@cartesi/rollupis a pre-release, published under thealphanpm tagCMT_INPUTSfrom files and writes the outputs next to them, and inside the Cartesi Machine it talks to the real rollup devicehttps://claude.ai/code/session_01YQk8hkw6zUJe38hM7LNd4r