Coralite v0.29.4 Released

Coralite version 0.29.4 is now available. This release delivers major enhancements to our rendering engine—transitioning from regex-based replacements to structured Abstract Syntax Tree (AST) manipulation—alongside an integrated AbortSignal pattern to simplify asynchronous lifecycle management inside client-side web components.

AST-Based Web Component Rendering #

To improve rendering correctness, Coralite has transitioned web component token replacement from basic regular expression replacement on raw HTML strings to an AST-driven pipeline. The build process now parses and serializes the HTML AST (templateAST) and token nodes (templateValues) directly into client-side JS chunks.

During execution, the internal _replaceTokens helper traverses these AST nodes and mutates values directly via exact string replacement (token.content). This replaces previous innerHTML assignments with structured output generated by dom-serializer. In addition, a WeakMap is introduced to clean up circular dependencies (such as parent, next, and previous nodes) and produce cross-referenced node IDs (_id) for tokens during serialization.

AbortSignal Injection for Component Lifecycle #

This release introduces automatic cleanup for asynchronous logic and event listeners. The framework now instantiates an AbortController when a dynamic web component connects to the DOM (connectedCallback) and binds the resulting AbortSignal to the client-side localContext.signal.

This signal is injected directly into user-defined client.script functions and forwarded to registered plugin client.helpers. Upon component disconnection (disconnectedCallback), the framework automatically triggers .abort(), tearing down pending async work and listeners without manual developer tracking. If the component remounts, a fresh AbortController is instantiated to restart the lifecycle safely.

typescript
Code copied!
  export default {
    script({ element, signal }) {
      // Event listener automatically cleaned up when component is unmounted
      window.addEventListener('resize', () => {
        console.log('Resized');
      }, { signal });
  
      // Ongoing fetch requests are aborted automatically on teardown
      fetch('/api/data', { signal })
        .then(res => res.json())
        .then(data => {
          element.textContent = data.message;
        });
    }
  }

Tooling and Test Decoupling #

To prevent component fixtures from leaking into production distributions, the testing environment has been decoupled from standard CLI execution. Build steps for tests now execute via tests/scripts/build-html.js instead of the main bin/coralite.js entrypoint. Additionally, unused paths and module imports have been removed from script-manager.js.

How to Upgrade #

To upgrade to the latest version, update your project dependencies:

bash
Code copied!
  npm install coralite@0.29.4
bash
Code copied!
  npm install coralite-scripts@0.29.4

Related posts

More blog posts

Start Building with Coralite!

Use the scaffolding script to get jump started into your next project with Coralite

Copied commandline!