-
Add support for
imports
inpackage.json
(#1691)This release adds basic support for the
imports
field inpackage.json
. It behaves similarly to theexports
field but only applies to import paths that start with#
. Theimports
field provides a way for a package to remap its own internal imports for itself, while theexports
field provides a way for a package to remap its external exports for other packages. This is useful because theimports
field respects the currently-configured conditions which means that the import mapping can change at run-time. For example:$ cat entry.mjs import '#example' $ cat package.json { "imports": { "#example": { "foo": "./example.foo.mjs", "default": "./example.mjs" } } } $ cat example.foo.mjs console.log('foo is enabled') $ cat example.mjs console.log('foo is disabled') $ node entry.mjs foo is disabled $ node --conditions=foo entry.mjs foo is enabled
Now that esbuild supports this feature too, import paths starting with
#
and any provided conditions will be respected when bundling:$ esbuild --bundle entry.mjs | node foo is disabled $ esbuild --conditions=foo --bundle entry.mjs | node foo is enabled
-
Fix using
npm rebuild
with theesbuild
package (#1703)Version 0.13.4 accidentally introduced a regression in the install script where running
npm rebuild
multiple times could fail after the second time. The install script creates a copy of the binary executable usinglink
followed byrename
. Usinglink
creates a hard link which saves space on the file system, andrename
is used for safety since it atomically replaces the destination.However, the
rename
syscall has an edge case where it silently fails if the source and destination are both the same link. This meant that the install script would fail after being run twice in a row. With this release, the install script now deletes the source after callingrename
in case it has silently failed, so this issue should now be fixed. It should now be safe to usenpm rebuild
with theesbuild
package. -
Fix invalid CSS minification of
border-radius
(#1702)CSS minification does collapsing of
border-radius
related properties. For example:/* Original CSS */ div { border-radius: 1px; border-top-left-radius: 5px; } /* Minified CSS */ div{border-radius:5px 1px 1px}
However, this only works for numeric tokens, not identifiers. For example:
/* Original CSS */ div { border-radius: 1px; border-top-left-radius: inherit; } /* Minified CSS */ div{border-radius:1px;border-top-left-radius:inherit}
Transforming this to
div{border-radius:inherit 1px 1px}
, as was done in previous releases of esbuild, is an invalid transformation and results in incorrect CSS. This release of esbuild fixes this CSS transformation bug.