Repository navigation
Releases: localnerve/web-component-build
Releases · localnerve/web-component-build
Release list
v4.0.0 - Templates API
v4.0.0
Breaking changes
templatesis now the API. The flathtmlPath/jsReplacementoptions are
removed; passing either throws a migration error. Describe html via
templates: [{ name, htmlPath, token }]. Pure-JS and pure-CSS builds pass no
templates. Seedocs/v4.0.0.mdfor 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.0htmls[]array and
thegetHtml()/htmlPathshorthands are removed. - Per-template CSS overrides. A template may supply its own
cssPath(and
cssLinkHref), falling back to the shared top-level values. The sharedcssPath
remains the canonical output css file. - Explicit
outputDirvalidation.build()now throws upfront whenoutputDir
does not exist or is not a directory, instead of failing withENOENTon 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 withsharedMultiTemplate: "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
- @4.0.0 - templates API by @localnerve in #79
Full Changelog: v3.5.1...v4.0.0
v3.5.0 - Syntax aware templates
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 newtemplatesoption. Shared
cssPath/cssLinkHrefare 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 existinggetHtml()/htmlPathshorthands 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
What's Changed
Added TrustedTypes support, Tree shakable browser helper exports
- @3.4.0-rc.1 - adding TrustedTypes support by @localnerve in #69
- @3.4.0-rc.2 - rc deployment by @localnerve in #70
- @3.4.0 - update exports for tree shaking by @localnerve in #71
- @3.4.0 - update escapeHtml, readme by @localnerve in #72
- @3.4.0 - update tests by @localnerve in #73
- @3.4.0 - add browser export, trusted type support by @localnerve in #74
Full Changelog: v3.3.1...v3.4.0
Version 3
v3.0.0
- node 22+
- terser@5.48.0
- devdeps
Version 2
v2.0.0
- Node 20.17+
- Remove Jest for node:test
- Update devdeps
Version 1.0
Version 1
Minimum Node version 18.17
- Cheerio 1.0.0
- Terser 5.31.5