Repository navigation
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