esbuild 0.13.9
-
Add support for
importsinpackage.json(#1691)This release adds basic support for the
importsfield inpackage.json. It behaves similarly to theexportsfield but only applies to import paths that start with#. Theimportsfield provides a way for a package to remap its own internal imports for itself, while theexportsfield provides a way for a package to remap its external exports for other packages. This is useful because theimportsfield 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 enabledNow 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 rebuildwith theesbuildpackage (#1703)Version 0.13.4 accidentally introduced a regression in the install script where running
npm rebuildmultiple times could fail after the second time. The install script creates a copy of the binary executable usinglinkfollowed byrename. Usinglinkcreates a hard link which saves space on the file system, andrenameis used for safety since it atomically replaces the destination.However, the
renamesyscall 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 callingrenamein case it has silently failed, so this issue should now be fixed. It should now be safe to usenpm rebuildwith theesbuildpackage. -
Fix invalid CSS minification of
border-radius(#1702)CSS minification does collapsing of
border-radiusrelated 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.