-
Fix
@jsx
and@jsxFrag
comments without trailing spacesThe
--jsx-factory
and--jsx-fragment
settings can be set on a per-file basis using// @jsx name
or// @jsxFrag name
comments. Comments of the form/* @jsx name */
or/* @jsxFrag name */
will also work. However, there was a bug where comments of the form/* @jsx name*/
or/* @jsxFrag name*/
(a multi-line comment without a trailing space at the end) did not work. This bug has been fixed, and you now no longer need a trailing space for multi-line comments. -
Minification improvements
-
The expression before a switch statement is now folded into the value. This means
fn(); switch (x) { ... }
turns intoswitch (fn(), x) { ... }
. -
Uses of
===
and!==
are converted to==
or!=
if the types of both sides can easily be statically determined. This means(x & 1) === 0
turns into(x & 1) == 0
. -
Equality comparisons are removed if both sides are boolean and one side is a constant. This means
!x === true
turns into!x
. -
Certain unary and binary operators are now removed if unused. This means
if (a() === b()) {}
turns intoa(), b();
. -
The comma operator is now extracted from certain expressions. This means
(a, b) + c
turns intoa, b + c
. -
Minification now takes advantage of the left-associativity of certain operators. This means
a && (b && c)
turns intoa && b && c
. -
Computed properties that are strings now become no longer computed. This means
{['a']: b}
turns into{a: b}
andclass { ['a'] = b }
turns intoclass { a = b }
. -
Repeated if-jump statements are now merged. This means
if (a) break; if (b) break;
turns intoif (a || b) break;
.
-
-
Fix issues with nested source maps (#638)
A nested source map happens when an input file has a valid
//# sourceMappingURL=
comment that points to a valid source map file. In that case, esbuild will read that source map and use it to map back to the original source code from the generated file. This only happens if you enable source map generation in esbuild via--sourcemap
. This release fixes the following issues:-
Generated source maps were incorrect when an input file had a nested source map and the input source map had more than one source file. This regression was introduced by an optimization in version 0.8.25 that parallelizes the generation of certain internal source map data structures. The index into the generated
sources
array was incorrectly incremented by 1 for every input file instead of by the number of sources in the input source map. This issue has been fixed and now has test coverage. -
Generated source maps were incorrect when an input file had a nested source map, the file starts with a local variable, the previous file ends with a local variable of that same type, and the input source map is missing a mapping at the start of the file. An optimization was added in version 0.7.18 that splices together local variable declarations from separate files when they end up adjacent to each other in the generated output file (i.e.
var a=0;var b=2;
becomesvar a=0,b=2;
whena
andb
are in separate files). The source map splicing was expecting a mapping at the start of the file and that isn't necessarily the case when using nested source maps. The optimization has been disabled for now to fix source map generation, and this specific case has test coverage.
-