-
Update to Unicode 15.0.0
The character tables that determine which characters form valid JavaScript identifiers have been updated from Unicode version 14.0.0 to the newly-released Unicode version 15.0.0. I'm not putting an example in the release notes because all of the new characters will likely just show up as little squares since fonts haven't been updated yet. But you can read https://www.unicode.org/versions/Unicode15.0.0/#Summary for more information about the changes.
-
Disallow duplicate lexically-declared names in nested blocks and in strict mode
In strict mode or in a nested block, it's supposed to be a syntax error to declare two symbols with the same name unless all duplicate entries are either
function
declarations or allvar
declarations. However, esbuild was overly permissive and allowed this when duplicate entries were eitherfunction
declarations orvar
declarations (even if they were mixed). This check has now been made more restrictive to match the JavaScript specification:// JavaScript allows this var a function a() {} { var b var b function c() {} function c() {} } // JavaScript doesn't allow this { var d function d() {} }
-
Add a type declaration for the new
empty
loader (#2755)I forgot to add this in the previous release. It has now been added.
This fix was contributed by @fz6m.
-
Add support for the
v
flag in regular expression literalsPeople are currently working on adding a
v
flag to JavaScript regular expresions. You can read more about this flag here: https://v8.dev/features/regexp-v-flag. This release adds support for parsing this flag, so esbuild will now no longer consider regular expression literals with this flag to be a syntax error. If the target is set to something other thanesnext
, esbuild will transform regular expression literals containing this flag into anew RegExp()
constructor call so the resulting code doesn't have a syntax error. This enables you to provide a polyfill forRegExp
that implements thev
flag to get your code to work at run-time. While esbuild doesn't typically adopt proposals until they're already shipping in a real JavaScript run-time, I'm adding it now because a) esbuild's implementation doesn't need to change as the proposal evolves, b) this isn't really new syntax since regular expression literals already have flags, and c) esbuild's implementation is a trivial pass-through anyway. -
Avoid keeping the name of classes with static
name
propertiesThe
--keep-names
property attempts to preserve the original value of thename
property for functions and classes even when identifiers are renamed by the minifier or to avoid a name collision. This is currently done by generating code to assign a string to thename
property on the function or class object. However, this should not be done for classes with a staticname
property since in that case the explicitly-definedname
property overwrites the automatically-generated class name. With this release, esbuild will now no longer attempt to preserve thename
property for classes with a staticname
property.