astroAssetsGeneration()
import { astroAssetsGeneration } from "@bearstudio/astro-assets-generation";
export default defineConfig({ integrations: [react(), astroAssetsGeneration()],});Returns an AstroIntegration named @bearstudio/astro-assets-generation. It
takes no options. It must be listed together with @astrojs/react, which
compiles the .tsx templates.
What it configures
Section titled “What it configures”The integration runs in the astro:config:setup hook and updates the Vite
configuration so Takumi’s WebAssembly renderer works in each output mode. The
native @takumi-rs/core bindings are never used.
output: "static" (default)
Section titled “output: "static" (default)”- Bundles
takumi-js,@takumi-rs/wasm,@takumi-rs/helpersand this library into the prerender bundle (ssr.noExternal). Prerendered chunks run in a temporary Node context that cannot resolve packages outside the app’s ownnode_modules, so they must be inlined. - Replaces Takumi’s internal backend import with a virtual module that reads
the
.wasmfile from disk and initialises the WebAssembly backend synchronously.
Server output or a route with prerender = false
Section titled “Server output or a route with prerender = false”- Keeps
takumi-jsexternal and bundles only this library. - Injects the location of the
.wasmfile as build-time constants. At runtime the file is looked up relative to the bundle first, then at the build-time absolute path, so deployments that move the bundle to another directory (Vercel builds in one path and runs in another) still find it.
All modes
Section titled “All modes”- Adds the
.wasmfile tovite.assetsInclude.@astrojs/vercelforwards this list to its file tracer, which copies the file into the serverless function bundle. - Excludes
takumi-jsfrom Vite’s dependency pre-bundling.
Runtime error
Section titled “Runtime error”If the .wasm file cannot be found when a server route renders, the error
message begins with:
[@bearstudio/astro-assets-generation] Could not locate the Takumi WASM binary at runtime.followed by the list of paths that were tried. See Troubleshooting.
Peer dependencies
Section titled “Peer dependencies”| Package | Versions |
|---|---|
astro |
^5.0.0 || ^6.0.0 || ^7.0.0 |
@astrojs/react |
any version matching your Astro |
react, react-dom |
18 or 19 |