github marko-js/marko marko@5.39.3

latest releases: marko@5.39.6, @marko/runtime-tags@6.1.6, marko@5.39.5...
6 hours ago

Patch Changes

  • #3210 5005d96 Thanks @DylanPiercey! - Add native lazy loading of tags.

    Tags can be lazily loaded by adding a load import attribute, in both the tags API and the class API:

    import Child from "./child.marko" with { load: "visible .selector" }
    
    <Child/>

    The attribute value is either render, which loads the module when the tag first renders in the browser, or one or more | separated triggers that start the load:

    • visible <selector> loads when an element matching the selector intersects the viewport (supports ?rootMargin=).
    • idle loads when the browser becomes idle (supports ?timeout=).
    • media <query> loads when the media query matches.
    • on<Event> <selector> loads when the event fires on an element matching the selector.

    Lazily loaded content still server renders, tree shakes, and resumes. The server tracks the assets each lazy section needs, writing inline trigger scripts into the HTML as it streams to avoid network waterfalls. Lazy loading requires a bundler integration through the linkAssets compiler option.

  • #3210 5005d96 Thanks @DylanPiercey! - Add compiler entry compilation and native asset handling for bundler integrations.

    • entry: "page" | "load" compiles a template as a top level page entry or a lazily loaded entry, replacing the deprecated output: "hydrate".
    • linkAssets: { runtime, onAsset } connects the bundler: onAsset(kind, file, id) is called for every discovered page and load entry, and runtime names a module whose flush function resolves an asset id into the HTML for its tags while rendering.

    With linkAssets configured the server tracks the assets needed by each page, writing their script tags into the streamed HTML (at the end of <head> when rendered, otherwise before the first flush).

  • #3208 9e043c0 Thanks @DylanPiercey! - Rework scope serialization and resumption: scopes serialize through a per-render context with canonical ids (smaller payloads; scopes that serialize no props are elided entirely), registered factories are invoked through that context, async serialized values (promises/streams) settle through the mutation queue so completions are no longer dropped or misordered across flushes, and embedded renders resume through the same machinery.

  • #3210 5005d96 Thanks @DylanPiercey! - Add version APIs for tooling: @marko/compiler now exports its version, translators export theirs, and getRuntimeVersion(translator) returns the resolved translator's version.

  • Updated dependencies [5005d96, 5005d96, 9e043c0, 5005d96]:

    • @marko/runtime-tags@6.1.4
    • @marko/compiler@5.39.64

Don't miss a new marko release

NewReleases is sending notifications on new releases.