Coralite v0.24.0: Build Modes, Client/Server Separation, and Plugin Enhancements #
Welcome to Coralite v0.24.0! This update is all about bringing structure, clarity, and robust debugging tools to your components and builds.
TL;DR of what's new:
- Build Modes: Introduced explicit Development and Production build modes with tailored performance profiles.
- Client/Server Separation: A major refactoring of the
defineComponentAPI to cleanly separate server-side setup and client-side execution. - Sourcemap Support: Automatic inline sourcemaps for component client scripts in development mode.
- Plugin Enhancements: A new
onBuildCompletelifecycle hook and robust configuration options for script compilation.
Development & Production Build Modes #
With v0.24.0, we have introduced explicit Development and Production build modes. This foundational change allows Coralite to optimize its internal behavior based on what you are trying to achieve.
In Development mode, Coralite prioritizes debugging. It utilizes SourceTextModule
for server-side evaluation and automatically injects inline sourcemaps into all of your client-side component
scripts. We also resolve bare module specifiers dynamically using createRequire relative to your
importing component.
In Production mode, Coralite strips out the debugging overhead and relies on highly optimized
esbuild transformations to compile your server-side scripts for maximum performance.
Client/Server Separation in defineComponent #
We've completely restructured the defineComponent API to enforce a strict and clear separation
between server-side Server-Side Rendering (SSR) logic and client-side browser execution.
Client-side configurations—including imports, SSR data preparation (setup), and browser execution
logic (script)—must now be nested within a dedicated client object. This structural
change prevents server-only logic from accidentally leaking into your client bundles and provides a much better
mental model for component authoring.
defineComponent({
client: {
imports: [{ specifier: 'my-package' }],
setup(props) {
// Runs on the server during SSR
return { serverTime: Date.now() }
},
script({ values }) {
// Runs on the client
console.log("Server time was:", values.serverTime)
}
}
})
Sourcemap Support for Easier Debugging #
As part of the new Development mode, Coralite now automatically generates and maps inline
sourcemaps for the code you write inside your client.script functions. Say goodbye to
struggling with minified or obscured errors in the browser console. Stack traces will now point directly back to
the original source lines in your component templates!
Plugin Enhancements & The onBuildComplete Hook #
We continue to expand the power available to plugin authors:
onBuildComplete: A new lifecycle event hook that triggers immediately after the entire build process (including all concurrent render queues) has finished.- Script Configuration: Plugin helpers can now receive robust static configuration objects
(
script.config) which are securely serialized and injected directly into the helper function context. - Namespace Exports: We've improved module handling with new
namespaceExportsupport, ensuring valid ESM syntax when combined with default or named exports.
How to Upgrade #
You can upgrade your projects today by updating your dependencies:
npm install coralite@latest
Happy building!
