@esbuild/win32-arm64
Advanced tools
Changelog
0.18.1
Fill in null
entries in input source maps (#3144)
If esbuild bundles input files with source maps and those source maps contain a sourcesContent
array with null
entries, esbuild previously copied those null
entries over to the output source map. With this release, esbuild will now attempt to fill in those null
entries by looking for a file on the file system with the corresponding name from the sources
array. This matches esbuild's existing behavior that automatically generates the sourcesContent
array from the file system if the entire sourcesContent
array is missing.
Support /* @__KEY__ */
comments for mangling property names (#2574)
Property mangling is an advanced feature that enables esbuild to minify certain property names, even though it's not possible to automatically determine that it's safe to do so. The safe property names are configured via regular expression such as --mangle-props=_$
(mangle all properties ending in _
).
Sometimes it's desirable to also minify strings containing property names, even though it's not possible to automatically determine which strings are property names. This release makes it possible to do this by annotating those strings with /* @__KEY__ */
. This is a convention that Terser added earlier this year, and which esbuild is now following too: https://github.com/terser/terser/pull/1365. Using it looks like this:
// Original code
console.log(
[obj.mangle_, obj.keep],
[obj.get('mangle_'), obj.get('keep')],
[obj.get(/* @__KEY__ */ 'mangle_'), obj.get(/* @__KEY__ */ 'keep')],
)
// Old output (with --mangle-props=_$)
console.log(
[obj.a, obj.keep],
[obj.get("mangle_"), obj.get("keep")],
[obj.get(/* @__KEY__ */ "mangle_"), obj.get(/* @__KEY__ */ "keep")]
);
// New output (with --mangle-props=_$)
console.log(
[obj.a, obj.keep],
[obj.get("mangle_"), obj.get("keep")],
[obj.get(/* @__KEY__ */ "a"), obj.get(/* @__KEY__ */ "keep")]
);
Support /* @__NO_SIDE_EFFECTS__ */
comments for functions (#3149)
Rollup has recently added support for /* @__NO_SIDE_EFFECTS__ */
annotations before functions to indicate that calls to these functions can be removed if the result is unused (i.e. the calls can be assumed to have no side effects). This release adds basic support for these to esbuild as well, which means esbuild will now parse these comments in input files and preserve them in output files. This should help people that use esbuild in combination with Rollup.
Note that this doesn't necessarily mean esbuild will treat these calls as having no side effects, as esbuild's parallel architecture currently isn't set up to enable this type of cross-file tree-shaking information (tree-shaking decisions regarding a function call are currently local to the file they appear in). If you want esbuild to consider a function call to have no side effects, make sure you continue to annotate the function call with /* @__PURE__ */
(which is the previously-established convention for communicating this).
Changelog
0.17.17
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
in package.json
for extends
in tsconfig.json
(#3058)
TypeScript 5.0 added the ability to use extends
in tsconfig.json
to reference a path in a package whose package.json
file contains an exports
map that points to the correct location. This doesn't automatically work in esbuild because tsconfig.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 the exports
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 a require()
import since that's what TypeScript appears to do. Specifically the require
condition will be active and the import
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 a NODE_PATH
directory. You're supposed to use NODE_PATH
for packages, but some people abuse this feature by putting files in that directory instead (e.g. node_modules/some-file.js
instead of node_modules/some-pkg/some-file.js
). The watch mode bug happens when you do this because esbuild first tries to read some-file.js
as a directory and then as a file. Watch mode was incorrectly waiting for some-file.js
to become a valid directory. This release fixes this edge case bug by changing watch mode to watch some-file.js
as a file when this happens.