Skip to content

v1.0.0

Choose a tag to compare

@lukeed lukeed released this 20 Oct 20:37
· 3 commits to main since this release
v1.0.0
ec98595

Breaking

  • Drop CommonJS support: tempura is an ES Module only. Node 22.12+ and Bun can still require() it. transform() drops its format option and always writes an ES Module (#24, f95279d)
  • Require Node 22 or later (bc0b619)
  • Merge tempura/esbuild and tempura/rollup into tempura/plugins, which exports an esbuild, rolldown, and vite object, each with transform() and compile() (ea4f135)
  • Replace the Rollup plugin with a Rolldown plugin (3d276fe)
  • Keep line breaks in text: two values on two lines no longer render on one, and a template keeps its last line break. A line that holds only a block or comment tag is removed, with its indent and line break, as in Handlebars. Closes #14, #17 (#25, 354a371)
  • Escape text outside of tags: a backtick, a backslash, and ${ now print as written. A \ that was added to make a backtick compile now prints too. Closes #11 (60626dc)
  • esc() escapes ' as ', so a value can't close a single-quoted attribute (46ca24e)
  • Throw on block arguments that can't be read: {{#block "value"}} used to drop the value silently (af69564)

Features

  • Add a Vite plugin: vite.transform() and vite.compile() work in builds and in the dev server (474c0d1)
  • Add a Rolldown plugin. Its hooks use a filter, so Rolldown calls them only for templates (3d276fe)
  • Block arguments can hold any expression in ( … ), and maps and lists can nest: {{#nav active=(page.section === 'docs')}} (af69564)
  • Block names can hold . and /: {{#icons.star}}, {{#partials/nav}} (1b411a1)
  • A render function uses the blocks that its call gives, in place of options.blocks (5ec406b)
  • Parse and compile templates faster: on 14 bongo templates, gen() went from 30 µs to 19 µs on Node, and from 34 µs to 18 µs on Bun, measured against the code before these changes (6a2656c, 7a76d0d, e531165, 68032e6, 57ba209)

Patches

  • Escape < as &lt;, not &lt, so XML output stays well-formed (0ade96f)
  • A prop, argument, or #var named x no longer overwrites the output (411e7f7)
  • Close a tag after its own braces and quotes: {"a": {{ n }}} keeps its last } (39da769)
  • A block argument with spaces no longer loses everything after the first space (af69564)
  • A one-character block name, such as {{#b}}, compiles (1b411a1)
  • loose: true no longer reads keywords, such as null or typeof, as props (709cd2b)
  • A bundle that uses only esc() no longer keeps the keyword list of loose mode (b36abef)
  • Throw clear errors for #else or #elif outside of #if or after #else, a close tag with no open block, #var with no =, and #expect names that can't be read (e803b6f)
  • Throw a clear error for a block tag with no name, such as {{# }} (57ba209)
  • Read {{#each items as(item)}} with no space before ( (e803b6f)
  • Nested #each loops no longer stop the outer loop after one pass (d6c6dec)

Chores

  • Convert the source to TypeScript, and check it in CI (ed30700)
  • Build with Bun.build() in place of bundt: everything goes to dist/ (687de3d)
  • Run CI with Bun (ab40317), on the main branch (e3510b6)
  • Update the benchmark numbers for Node 26 and Bun 1.4, in bench/ and the readme (#22, 1efe40d, 8d15dff)
  • Time library loads in the bench with require() (ef20ed8)
  • Load tempura in the bench and the worker example from dist/ (8cdb804)
  • Fix the import path of the TypeScript example (2bd23fe)
  • Document block arguments, block names, call-time blocks (284dbc0), plugins (474c0d1), and whitespace (#25)
  • Fix the readme badges, and update the readme size (7917f25, 34ed2fa, bf3bef0)
  • Add tests for nested #each loops (bbf38ce)

Full Changelog: v0.4.1...v1.0.0