Skip to content

Releases: localnerve/web-component-build

v4.0.0 - Templates API

Choose a tag to compare

@localnerve localnerve released this 11 Sep 16:30
71b6bae

v4.0.0

Breaking changes

  • templates is now the API. The flat htmlPath / jsReplacement options are
    removed; passing either throws a migration error. Describe html via
    templates: [{ name, htmlPath, token }]. Pure-JS and pure-CSS builds pass no
    templates. See docs/v4.0.0.md for the full migration guide.
  • HTML outputs are a named map. The result now exposes html[name] (each
    { name, path, getHtml }) keyed by template name. The v3.5.0 htmls[] array and
    the getHtml() / htmlPath shorthands are removed.
  • Per-template CSS overrides. A template may supply its own cssPath (and
    cssLinkHref), falling back to the shared top-level values. The shared cssPath
    remains the canonical output css file.
  • Explicit outputDir validation. build() now throws upfront when outputDir
    does not exist or is not a directory, instead of failing with ENOENT on the first
    write. The library still never creates or cleans directories — that stays the
    caller's responsibility.
  • Documented constraint: tokens must be unique in the source file. The injector
    replaces the first occurrence of each token; a token string also present in a comment
    or other literal redirects injection there.

Unchanged from v3.5.0

  • Syntax-aware (acorn) injection: markup is spliced into the token's string/template
    literal with escaping for that quote context — safe with quotes, backticks, ${,
    and backslashes in the payload.
  • Output-filename collision detection (duplicate resolved names throw).
  • Multi-template support; shared css/link are embedded in the first template that uses them by default (sharedMultiTemplate: "first"), or in every template with sharedMultiTemplate: "every".

Migration example

 const result = await build(outputDir, {
   jsPath: '/…/component.js',
   cssPath: '/…/component.css',
-  htmlPath: '/…/index.html',
-  jsReplacement: '__JS_REPLACEMENT__'
+  templates: [
+    { name: 'index', htmlPath: '/…/index.html', token: '__JS_REPLACEMENT__' }
+  ]
 });

-await result.getHtml();
+await result.html.index.getHtml();

What's Changed

Full Changelog: v3.5.1...v4.0.0

v3.5.0 - Syntax aware templates

Choose a tag to compare

@localnerve localnerve released this 08 Sep 13:52
9c49259

v3.5.0

Highlights

  • Syntax-aware template injection. CSS/HTML/link markup is now injected into the
    component's JavaScript via an acorn parse + quote-context-aware splice
    (lib/replace.js) instead of brittle text replacement with a per-line backslash hack.
    Injected markup may now safely contain ', ", `, ${, and backslashes without
    corrupting the surrounding JS.
  • Multiple templates. A component can now define several HTML templates (e.g. default /
    error / empty states), each with its own token, via the new templates option. Shared
    cssPath/cssLinkHref are applied to every template; a template may override its own
    cssLinkHref.
  • Result exposes htmls. An ordered array of { name, path, getHtml }, one per
    template. The existing getHtml() / htmlPath shorthands now resolve to the first
    html output and remain for backward compatibility.
  • Output-collision fix. Duplicate resolved html output names now throw instead of
    silently overwriting each other (previously all templates shared <basename>.html).

Backward compatibility

Non-breaking. The flat htmlPath + jsReplacement options continue to work and are
synthesized into a single template internally. All existing fixtures pass unmodified.

New dependency

  • acorn — JavaScript parser used for token location and safe injection.

Migration notes

None required for v3.4.x callers. To adopt multi-template, pass a templates array; see
docs/v3.5.0.md.

What's Changed

  • @3.5.0 - syntax aware templates, multiple outputs by @localnerve in #77

Full Changelog: v3.4.2...v3.5.0

Version 3.4.0

Choose a tag to compare

@localnerve localnerve released this 03 Sep 21:21
42e621b

What's Changed

Added TrustedTypes support, Tree shakable browser helper exports

Full Changelog: v3.3.1...v3.4.0

Version 3

Choose a tag to compare

@localnerve localnerve released this 03 Sep 21:19
c5a38a2

v3.0.0

  • node 22+
  • terser@5.48.0
  • devdeps

Version 2

Choose a tag to compare

@localnerve localnerve released this 28 Apr 17:54
f363722

v2.0.0

  • Node 20.17+
  • Remove Jest for node:test
  • Update devdeps

Version 1.0

Choose a tag to compare

@localnerve localnerve released this 10 Aug 17:09
5236b72

Version 1

Minimum Node version 18.17

  • Cheerio 1.0.0
  • Terser 5.31.5