-
Improve ambiguous import handling (#723)
It is an error to try to import a name from a file where there are multiple matching exports due to multiple
export * from
statements from files which export that name. This release contains a few improvements to ambiguous import handling:-
This release fixes a bug where named export shadowing didn't work correctly with multiple levels of re-exports. A named export closer in the re-export chain is supposed to hide a named export deeper in the re-export chain without causing an ambiguous import. The bug caused this case to be incorrectly flagged as an error even though it should have been allowed. This case is now allowed without an error.
-
Previously the error message just said that there was an ambiguous import but didn't have any additional information. With this release, the error message also points out where the two different exports that have collided are in their original source files. Hopefully this should make it quicker to diagnose these types of issues.
-
Real JavaScript environments only treat ambiguous imports as an error if they are explicitly a named import. Using the
import * as
syntax and then accessing the ambiguous import with a property access results inundefined
instead of an error. Previously esbuild also treated this case as an error because it automatically rewrites star-import syntax to named-import syntax to improve tree shaking. With this release, this case is now treated as a warning instead of an error and the import will be automatically replaced with anundefined
literal in the bundled code.
-
-
Reuse automatically-generated temporary
*.node
files (#719)The previous change to hide the automatically-generated N-API native node extensions from Yarn 2 writes these
*.node
files to the system's temporary directory. A new one was being created on each run which is wasteful even though they are only a few kilobytes in size. With this release*.node
files will now be reused if they are already present in the system's temporary directory, so a new one is no longer created on each run. This fix was contributed by @kzc. -
Fix the serve API with
outfile
(#707)This release fixes a bug where the serve API did not work with the
outfile
setting. Using this setting with the serve API should now work fine. -
Warn about duplicate keys in object literals
Using a duplicate key in an object literal such as
{x: 1, x: 2}
is now a warning. This is allowed in JavaScript but results in subsequent keys overwriting the previous key. It's usually a copy/paste error and isn't ever useful so it's worth warning about. -
Avoid generating duplicate keys in JSON metadata
The
output
map that is generated when themetafile
feature is active could potentially have duplicate keys if thefile
loader is used, there are multiple entry points, and two or more entry points reference the same file. This is harmless because both keys mapped to the same value, but it's confusing and unnecessary. Duplicate keys are no longer present in the output map in this latest release. -
Make the JSON metafile structure match the type definitions (#726)
Previously
imports
and/orexports
could be missing from entries in theoutput
map in certain cases (specifically for source maps and files loaded with thefile
loader). This was problematic because the TypeScript type definitions for the metafile say that theimports
andexports
properties are non-optional. With this release, theimports
andexports
properties are now always present so the existing TypeScript type definitions are now accurate. -
Update from Go 1.15.5 to Go 1.15.7
The version of Go used to build the released binary executables on npm is now Go 1.15.7. This change shouldn't result in any visible changes to esbuild. It was only upgraded because the Go extension for the VSCode IDE now uses the official
gopls
Go language service and this extension wanted the latest version of Go.