Skip to content

v7.0.0

Choose a tag to compare

@Havunen Havunen released this 25 Sep 11:01
· 7 commits to master since this release
f9f0df6

7.0.0

This release fixes many cases where the plugin generated wrong or invalid code, adds compile-time errors for mistakes it used to accept silently, and roughly halves the plugin's own transform cost.

Breaking changes

  • Node.js 24 or newer is required. The previous requirement was Node.js 18 or newer.
  • Duplicate props are now a compile error. Before, the last value silently won.
    • Repeated names on elements and components: <p prop prop />, two keys, two refs, repeated onComponent* hooks or $ flags.
    • Two names that set the same prop on an element: className + class, htmlFor + for, tabIndex + tabindex, strokeWidth + stroke-width, xlinkHref + xlink:href.
  • key without a value is now a compile error. <li key /> used to compile to key: true. Give the key an explicit value.

Bug fixes

Imports and module output

  • imports: false: when several files were compiled with the same config (babel-loader, loadOptionsSync), only the first file got var createVNode = Inferno.createVNode. Every later file failed at runtime with ReferenceError: createVNode is not defined. The plugin no longer keeps state between files.
  • imports: false: that declaration now goes at the top of the file, after the imports and after the file's own Inferno declaration. Before, it was inserted just before the first statement that contained JSX, so a hoisted function called earlier in the file ran while createVNode was still undefined.
  • sourceType: "script", and "unambiguous" on a file without import/export: the plugin added an import declaration, which is invalid in a script. It now uses require("inferno") there.
  • imports: "true" given as a string was read as a module name. It is now read as true.

Children

  • <div children={x} /> was always compiled as a single vnode (HasVNodeChildren). As a result, strings and arrays passed that way failed Inferno's flag validation in development and broke mounting in production. Now only JSX values are flagged as a single vnode, and Inferno normalizes other values at runtime. <Fragment children={a} /> had the same bug.
  • children=<span /> (JSX without braces) was silently dropped. It now works.
  • Spread children like <div>{...items}</div> were silently dropped. They now compile to [...items], the same as TypeScript and esbuild.

Props

  • A __proto__ prop changed the props object's prototype instead of passing the prop. It is now written as a computed key, {["__proto__"]: x}, so the component receives it as an ordinary prop.
  • A component with both ref and onComponent* hooks crashed the plugin. They are now merged, and the hooks take precedence.
  • <>...</> fragments ignored the defineAll option.

String attributes

  • Line breaks inside quoted attributes, such as a multi-line className, produced invalid JavaScript.
  • Backslashes were treated as JavaScript escape sequences: pattern="\d{3}" became d{3}, and "\9" was a syntax error in modules.
  • HTML entities were not decoded: title="a&amp;b" stayed a&amp;b.

SVG attributes

  • lengthAdjust, xChannelSelector and yChannelSelector were lowercased. SVG attribute names are case-sensitive, so browsers ignored them.
  • fontWidth, maskType, textOverflow and whiteSpace now become font-width, mask-type, text-overflow and white-space.
  • Tests now cover every attribute in MDN's SVG attribute reference.

Tag names

  • Namespaced tags like <a:b /> crashed with path.replaceWith() a falsy node. They now throw a clear error that points to the tag.
  • <Foo-bar /> crashed the plugin. It now compiles as a DOM element.
  • <Foo.bar-baz /> crashed the plugin. It now compiles to Foo["bar-baz"].
  • <a-b.c /> now reports that a-b is not a valid variable name.

Source maps

  • Generated createVNode, createFragment, createTextVNode and normalizeProps calls now have the location of the JSX they replace, so source maps point to the JSX.

Performance

  • The plugin's own transform time and allocations are about halved: 49% less time and 48% fewer bytes allocated, as a geometric mean over 9 benchmark cases. A full transformSync is about 16% faster and allocates about 14% less. The generated code and source maps are unchanged.
  • The Babel 8 warning "Usage of builders starting with an uppercase letter such as StringLiteral has been deprecated" is no longer printed.

Development

  • New benchmark suite in bench/: npm run bench, bench:quick, bench:compare and bench:profile. See the README.
  • The test suite is much larger.
  • ESLint config updated for ESLint 10. Dev dependencies updated, including Babel 8.0.6 and Mocha 12.