@bosejs/compiler
v0.2.1
Published
The 'Brain' of Bose framework. Handles closure extraction and resumability shredding.
Maintainers
Readme
@bosejs/compiler
The Babel plugin that powers Bosejs — extracts
$()closures into lazy resumable chunks.
What it does
The compiler is the "brain" of Bosejs. It transforms your source files at build time:
- Finds every
$()closure in your component code - Extracts it into its own standalone JS chunk file
- Replaces it with a reference object
{ chunk: 'chunk_abc123.js' } - Injects a stable signal ID so the runtime can sync state on resumption
The result: your page ships with zero JS. Chunks are fetched lazily on first user interaction.
Install
This package is installed automatically when you install @bosejs/core. You don't need to install it directly.
npm install @bosejs/core # pulls in @bosejs/compiler automaticallyHow $() works
You write:
const increment = $(() => {
count.value++;
});The compiler outputs (in your page):
const increment = { chunk: 'chunk_a1b2c3d4e.js', props: [] };And creates public/chunks/chunk_a1b2c3d4e.js:
// Lazily fetched only when the user first clicks
const { count } = __BOSE_STATE__;
count.value++;Chunk IDs are deterministic (based on file content hash) — the same source always produces the same chunk ID across builds.
License
MIT © Bosejs Contributors
