-
Allow implicit
./
in CSS@import
paths (#1494)In the browser, the paths inside CSS
@import
rules are implicitly relative to the path of the current CSS style sheet. Previously esbuild used node's JS path resolution rules in CSS as well, which required a./
or../
prefix for a path to be considered a relative path. Paths without that prefix are considered package paths and are searched for insidenode_modules
instead.With this release, esbuild will now first try to interpret the path as a relative path and then fall back to interpreting it as a package path if nothing exists at that relative path. This feature was originally added in version 0.7.18 but only worked for CSS
url()
tokens. In this release it now also works for@import
rules.This feature was contributed by @pd4d10.
-
Fix lowering of nullish coalescing assignment edge case (#1493)
This release fixes a bug where lowering of the
??=
nullish coalescing assignment operator failed when the target environment supported nullish coalescing and private class fields but not nullish coalescing assignment. An example target environment with this specific feature support matrix combination is node 14.8. This edge case is now lowered correctly:// Original code class A { #a; f() { this.#a ??= 1; } } // Old output (with --target=node14.8) panic: Unexpected expression of type *js_ast.EPrivateIdentifier // New output (with --target=node14.8) class A { #a; f() { this.#a ?? (this.#a = 1); } }
-
Fix public fields being inserted before
super()
call (#1497)The helper function that esbuild uses to emulate the new public class field syntax can potentially be inserted into the class constructor before the
super()
call. That is problematic because the helper function makes use ofthis
, andthis
must only be used after thesuper()
call. This release fixes a case where this happens when minification is enabled:// Original code class A extends B { x; constructor() { f(); super(); } } // Old output (with --minify-syntax --target=es6) class A extends B { constructor() { __publicField(this, "x"); f(), super(); } } // New output (with --minify-syntax --target=es6) class A extends B { constructor() { f(); super(); __publicField(this, "x"); } }
-
Fix lowering of static private methods in class expressions (#1498)
Previously static private methods were lowered incorrectly when present in class expressions. The class expression itself was missing in the output due to an oversight (variable shadowing). This issue has been fixed:
// Original code (class { static #x() {} }); // Old output (with --target=es6) var _x, _a, x_fn; __privateAdd(_a, _x), _x = new WeakSet(), x_fn = function() { }, __privateAdd(_a, _x), _a; // New output (with --target=es6) var _x, _a, x_fn; _a = class { }, _x = new WeakSet(), x_fn = function() { }, __privateAdd(_a, _x), _a;