-
Fix CSS nesting transform for top-level
&
(#3052)Previously esbuild could crash with a stack overflow when lowering CSS nesting rules with a top-level
&
, such as in the code below. This happened because esbuild's CSS nesting transform didn't handle top-level&
, causing esbuild to inline the top-level selector into itself. This release handles top-level&
by replacing it with the:scope
pseudo-class:/* Original code */ &, a { .b { color: red; } } /* New output (with --target=chrome90) */ :is(:scope, a) .b { color: red; }
-
Support
exports
inpackage.json
forextends
intsconfig.json
(#3058)TypeScript 5.0 added the ability to use
extends
intsconfig.json
to reference a path in a package whosepackage.json
file contains anexports
map that points to the correct location. This doesn't automatically work in esbuild becausetsconfig.json
affects esbuild's path resolution, so esbuild's normal path resolution logic doesn't apply.This release adds support for doing this by adding some additional code that attempts to resolve the
extends
path using theexports
field. The behavior should be similar enough to esbuild's main path resolution logic to work as expected.Note that esbuild always treats this
extends
import as arequire()
import since that's what TypeScript appears to do. Specifically therequire
condition will be active and theimport
condition will be inactive. -
Fix watch mode with
NODE_PATH
(#3062)Node has a rarely-used feature where you can extend the set of directories that node searches for packages using the
NODE_PATH
environment variable. While esbuild supports this too, previously a bug prevented esbuild's watch mode from picking up changes to imported files that were contained directly in aNODE_PATH
directory. You're supposed to useNODE_PATH
for packages, but some people abuse this feature by putting files in that directory instead (e.g.node_modules/some-file.js
instead ofnode_modules/some-pkg/some-file.js
). The watch mode bug happens when you do this because esbuild first tries to readsome-file.js
as a directory and then as a file. Watch mode was incorrectly waiting forsome-file.js
to become a valid directory. This release fixes this edge case bug by changing watch mode to watchsome-file.js
as a file when this happens.