-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dependency esbuild to v0.14.25 #240
Conversation
Pull Request Test Coverage Report for Build 1932781297
💛 - Coveralls |
Codecov Report
@@ Coverage Diff @@
## master #240 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 248 248
Branches 52 52
=========================================
Hits 248 248
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
a936c28
to
2c485bd
Compare
2c485bd
to
b9d6c8b
Compare
b9d6c8b
to
b7b42f9
Compare
b7b42f9
to
486cbf2
Compare
5b8fdfe
to
bd91519
Compare
2a5ccc9
to
7b4d56a
Compare
7b4d56a
to
0b9eef9
Compare
0b9eef9
to
4b2f604
Compare
4b2f604
to
180e2cb
Compare
180e2cb
to
cf668a2
Compare
cf668a2
to
58479db
Compare
58479db
to
b662d05
Compare
2b48018
to
4a6ad99
Compare
4a6ad99
to
8b5a4a8
Compare
8b5a4a8
to
9ca85e7
Compare
9ca85e7
to
8d5a9c2
Compare
8d5a9c2
to
d657a4c
Compare
d657a4c
to
e347055
Compare
e347055
to
65f9b4e
Compare
65f9b4e
to
2a17eca
Compare
2a17eca
to
700f8f0
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
700f8f0
to
43a0276
Compare
43a0276
to
aadb498
Compare
aadb498
to
e3682f0
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This PR contains the following updates:
0.11.19
->0.14.25
Release Notes
evanw/esbuild
v0.14.25
Compare Source
Reduce minification of CSS transforms to avoid Safari bugs (#2057)
In Safari, applying a 3D CSS transform to an element can cause it to render in a different order than applying a 2D CSS transform even if the transformation matrix is identical. I believe this is a bug in Safari because the CSS
transform
specification doesn't seem to distinguish between 2D and 3D transforms as far as rendering order:This bug means that minifying a 3D transform into a 2D transform must be avoided even though it's a valid transformation because it can cause rendering differences in Safari. Previously esbuild sometimes minified 3D CSS transforms into 2D CSS transforms but with this release, esbuild will no longer do that:
Minification now takes advantage of the
?.
operatorThis adds new code minification rules that shorten code with the
?.
optional chaining operator when the result is equivalent:This only takes effect when minification is enabled and when the configured target environment is known to support the optional chaining operator. As always, make sure to set
--target=
to the appropriate language target if you are running the minified code in an environment that doesn't support the latest JavaScript features.Add source mapping information for some non-executable tokens (#1448)
Code coverage tools can generate reports that tell you if any code exists that has not been run (or "covered") during your tests. You can use this information to add additional tests for code that isn't currently covered.
Some popular JavaScript code coverage tools have bugs where they incorrectly consider lines without any executable code as uncovered, even though there's no test you could possibly write that would cause those lines to be executed. For example, they apparently complain about the lines that only contain the trailing
}
token of an object literal.With this release, esbuild now generates source mappings for some of these trailing non-executable tokens. This may not successfully work around bugs in code coverage tools because there are many non-executable tokens in JavaScript and esbuild doesn't map them all (the drawback of mapping these extra tokens is that esbuild will use more memory, build more slowly, and output a bigger source map). The true solution is to fix the bugs in the code coverage tools in the first place.
Fall back to WebAssembly on Android x64 (#2068)
Go's compiler supports trivial cross-compiling to almost all platforms without installing any additional software other than the Go compiler itself. This has made it very easy for esbuild to publish native binary executables for many platforms. However, it strangely doesn't support cross-compiling to Android x64 without installing the Android build tools. So instead of publishing a native esbuild binary executable to npm, this release publishes a WebAssembly fallback build. This is essentially the same as the
esbuild-wasm
package but it's installed automatically when you install theesbuild
package on Android x64. So packages that depend on theesbuild
package should now work on Android x64. If you want to use a native binary executable of esbuild on Android x64, you may be able to build it yourself from source after installing the Android build tools.Update to Go 1.17.8
The version of the Go compiler used to compile esbuild has been upgraded from Go 1.17.7 to Go 1.17.8, which fixes the RISC-V 64-bit build. Compiler optimizations for the RISC-V 64-bit build have now been re-enabled.
v0.14.24
Compare Source
Allow
es2022
as a target environment (#2012)TypeScript recently added support for
es2022
as a compilation target so esbuild now supports this too. Support for this is preliminary as there is no published ES2022 specification yet (i.e. https://tc39.es/ecma262/2021/ exists but https://tc39.es/ecma262/2022/ is a 404 error). The meaning of esbuild'ses2022
target may change in the future when the specification is finalized. Right now I have made thees2022
target enable support for the syntax-related finished proposals that are marked as2022
:I have also included the "arbitrary module namespace names" feature since I'm guessing it will end up in the ES2022 specification (this syntax feature was added to the specification without a proposal). TypeScript has not added support for this yet.
Match
define
to strings in index expressions (#2050)With this release, configuring
--define:foo.bar=baz
now matches and replaces bothfoo.bar
andfoo['bar']
expressions in the original source code. This is necessary for people who have enabled TypeScript'snoPropertyAccessFromIndexSignature
feature, which prevents you from using normal property access syntax on a type with an index signature such as in the following code:Previously esbuild would generate the following output with
--define:foo.bar=baz
:Now esbuild will generate the following output instead:
Add
--mangle-quoted
to mangle quoted properties (#218)The
--mangle-props=
flag tells esbuild to automatically rename all properties matching the provided regular expression to shorter names to save space. Previously esbuild never modified the contents of string literals. In particular,--mangle-props=_
would manglefoo._bar
but notfoo['_bar']
. There are some coding patterns where renaming quoted property names is desirable, such as when using TypeScript'snoPropertyAccessFromIndexSignature
feature or when using TypeScript's discriminated union narrowing behavior:The
'_foo' in value
check tells TypeScript to narrow the type ofvalue
toFoo
in the true branch and toBar
in the false branch. Previously esbuild didn't mangle the property name'_foo'
because it was inside a string literal. With this release, you can now use--mangle-quoted
to also rename property names inside string literals:Parse and discard TypeScript
export as namespace
statements (#2070)TypeScript
.d.ts
type declaration files can sometimes contain statements of the formexport as namespace foo;
. I believe these serve to declare that the module adds a property of that name to the global object. You aren't supposed to feed.d.ts
files to esbuild so this normally doesn't matter, but sometimes esbuild can end up having to parse them. One such case is if you import a type-only package who'smain
field inpackage.json
is a.d.ts
file.Previously esbuild only allowed
export as namespace
statements inside adeclare
context:Now esbuild will also allow these statements outside of a
declare
context:These statements are still just ignored and discarded.
Strip import assertions from unrecognized
import()
expressions (#2036)The new "import assertions" JavaScript language feature adds an optional second argument to dynamic
import()
expressions, which esbuild does support. However, this optional argument must be stripped when targeting older JavaScript environments for which this second argument would be a syntax error. Previously esbuild failed to strip this second argument in cases when the first argument toimport()
wasn't a string literal. This problem is now fixed:Remove simplified statement-level literal expressions (#2063)
With this release, esbuild now removes simplified statement-level expressions if the simplified result is a literal expression even when minification is disabled. Previously this was only done when minification is enabled. This change was only made because some people are bothered by seeing top-level literal expressions. This change has no effect on code behavior.
Ignore
.d.ts
rules inpaths
intsconfig.json
files (#2074, #2075)TypeScript's
tsconfig.json
configuration file has apaths
field that lets you remap import paths to alternative files on the file system. This field is interpreted by esbuild during bundling so that esbuild's behavior matches that of the TypeScript type checker. However, people sometimes override import paths to JavaScript files to instead point to a.d.ts
TypeScript type declaration file for that JavaScript file. The intent of this is to just use the remapping for type information and not to actually import the.d.ts
file during the build.With this release, esbuild will now ignore rules in
paths
that result in a.d.ts
file during path resolution. This means code that does this should now be able to be bundled without modifying itstsconfig.json
file to remove the.d.ts
rule. This change was contributed by @magic-akari.Disable Go compiler optimizations for the Linux RISC-V 64bit build (#2035)
Go's RISC-V 64bit compiler target has a fatal compiler optimization bug that causes esbuild to crash when it's run: https://github.com/golang/go/issues/51101. As a temporary workaround until a version of the Go compiler with the fix is published, Go compiler optimizations have been disabled for RISC-V. The 7.7mb esbuild binary executable for RISC-V is now 8.7mb instead. This workaround was contributed by @piggynl.
v0.14.23
Compare Source
Update feature database to indicate that node 16.14+ supports import assertions (#2030)
Node versions 16.14 and above now support import assertions according to these release notes. This release updates esbuild's internal feature compatibility database with this information, so esbuild no longer strips import assertions with
--target=node16.14
:Basic support for CSS
@layer
rules (#2027)This adds basic parsing support for a new CSS feature called
@layer
that changes how the CSS cascade works. Adding parsing support for this rule to esbuild means esbuild can now minify the contents of@layer
rules:You can read more about
@layer
here:Note that the support added in this release is only for parsing and printing
@layer
rules. The bundler does not yet know about these rules and bundling with@layer
may result in behavior changes since these new rules have unusual ordering constraints that behave differently than all other CSS rules. Specifically the order is derived from the first instance while with every other CSS rule, the order is derived from the last instance.v0.14.22
Compare Source
Preserve whitespace for token lists that look like CSS variable declarations (#2020)
Previously esbuild removed the whitespace after the CSS variable declaration in the following CSS:
However, that broke rendering in Chrome as it caused Chrome to ignore the entire rule. This did not break rendering in Firefox and Safari, so there's a browser bug either with Chrome or with both Firefox and Safari. In any case, esbuild now preserves whitespace after the CSS variable declaration in this case.
Ignore legal comments when merging adjacent duplicate CSS rules (#2016)
This release now generates more compact minified CSS when there are legal comments in between two adjacent rules with identical content:
Block
onResolve
andonLoad
untilonStart
ends (#1967)This release changes the semantics of the
onStart
callback. AllonStart
callbacks from all plugins are run concurrently so that a slow plugin doesn't hold up the entire build. That's still the case. However, previously the only thing waiting for theonStart
callbacks to finish was the end of the build. This meant thatonResolve
and/oronLoad
callbacks could sometimes run beforeonStart
had finished. This was by design but violated user expectations. With this release, allonStart
callbacks must finish before anyonResolve
and/oronLoad
callbacks are run.Add a self-referential
default
export to the JS API (#1897)Some people try to use esbuild's API using
import esbuild from 'esbuild'
instead ofimport * as esbuild from 'esbuild'
(i.e. using a default import instead of a namespace import). There is nodefault
export so that wasn't ever intended to work. But it would work sometimes depending on which tools you used and how they were configured so some people still wrote code this way. This release tries to make that work by adding a self-referentialdefault
export that is equal to esbuild's module namespace object.More detail: The published package for esbuild's JS API is in CommonJS format, although the source code for esbuild's JS API is in ESM format. The original ESM code for esbuild's JS API has no export named
default
so using a default import like this doesn't work with Babel-compatible toolchains (since they respect the semantics of the original ESM code). However, it happens to work with node-compatible toolchains because node's implementation of importing CommonJS from ESM broke compatibility with existing conventions and automatically creates adefault
export which is set tomodule.exports
. This is an unfortunate compatibility headache because it means thedefault
import only works sometimes. This release tries to fix this by explicitly creating a self-referentialdefault
export. It now doesn't matter if you doesbuild.build()
,esbuild.default.build()
, oresbuild.default.default.build()
because they should all do the same thing. Hopefully this means people don't have to deal with this problem anymore.Handle
write
errors when esbuild's child process is killed (#2007)If you type Ctrl+C in a terminal when a script that uses esbuild's JS library is running, esbuild's child process may be killed before the parent process. In that case calls to the
write()
syscall may fail with anEPIPE
error. Previously this resulted in an uncaught exception because esbuild didn't handle this case. Starting with this release, esbuild should now catch these errors and redirect them into a generalThe service was stopped
error which should be returned from whatever top-level API calls were in progress.Better error message when browser WASM bugs are present (#1863)
Safari's WebAssembly implementation appears to be broken somehow, at least when running esbuild. Sometimes this manifests as a stack overflow and sometimes as a Go panic. Previously a Go panic resulted in the error message
Can't find variable: fs
but this should now result in the Go panic being printed to the console. Using esbuild's WebAssembly library in Safari is still broken but now there's a more helpful error message.More detail: When Go panics, it prints a stack trace to stderr (i.e. file descriptor 2). Go's WebAssembly shim calls out to node's
fs.writeSync()
function to do this, and it converts calls tofs.writeSync()
into calls toconsole.log()
in the browser by providing a shim forfs
. However, Go's shim code stores the shim onwindow.fs
in the browser. This is undesirable because it pollutes the global scope and leads to brittle code that can break if other code also useswindow.fs
. To avoid this, esbuild shadows the global object by wrapping Go's shim. But that broke bare references tofs
since the shim is no longer stored onwindow.fs
. This release now stores the shim in a local variable namedfs
so that bare references tofs
work correctly.Undo incorrect dead-code elimination with destructuring (#1183)
Previously esbuild eliminated these statements as dead code if tree-shaking was enabled:
This is incorrect because both of these lines will throw an error when evaluated. With this release, esbuild now preserves these statements even when tree shaking is enabled.
Update to Go 1.17.7
The version of the Go compiler used to compile esbuild has been upgraded from Go 1.17.6 to Go 1.17.7, which contains a few compiler and security bug fixes.
v0.14.21
Compare Source
Handle an additional
browser
map edge case (#2001, #2002)There is a community convention around the
browser
field inpackage.json
that allows remapping import paths within a package when the package is bundled for use within a browser. There isn't a rigorous definition of how it's supposed to work and every bundler implements it differently. The approach esbuild uses is to try to be "maximally compatible" in that if at least one bundler exhibits a particular behavior regarding thebrowser
map that allows a mapping to work, then esbuild also attempts to make that work.I have a collection of test cases for this going here: https://github.com/evanw/package-json-browser-tests. However, I was missing test coverage for the edge case where a package path import in a subdirectory of the package could potentially match a remapping. The "maximally compatible" approach means replicating bugs in Browserify's implementation of the feature where package paths are mistaken for relative paths and are still remapped. Here's a specific example of an edge case that's now handled:
entry.js
:node_modules/pkg/package.json
:node_modules/pkg/sub/foo.js
:node_modules/pkg/sub/bar.js
:The import path
sub
inrequire('sub')
is mistaken for a relative path by Browserify due to a bug in Browserify, so Browserify treats it as if it were./sub
instead. This is a Browserify-specific behavior and currently doesn't happen in any other bundler (except for esbuild, which attempts to replicate Browserify's bug).Previously esbuild was incorrectly resolving
./sub
relative to the top-level package directory instead of to the subdirectory in this case, which meant./sub
was incorrectly matching"./sub": "./sub/foo.js"
instead of"./sub/sub": "./sub/bar.js"
. This has been fixed so esbuild can now emulate Browserify's bug correctly in this edge case.Support for esbuild with Linux on RISC-V 64bit (#2000)
With this release, esbuild now has a published binary executable for the RISC-V 64bit architecture in the
esbuild-linux-riscv64
npm package. This change was contributed by @piggynl.v0.14.20
Compare Source
Fix property mangling and keyword properties (#1998)
Previously enabling property mangling with
--mangle-props=
failed to add a space before property names after a keyword. This bug has been fixed:v0.14.19
Compare Source
Special-case
const
inlining at the top of a scope (#1317, #1981)The minifier now inlines
const
variables (even across modules during bundling) if a certain set of specific requirements are met:const
variables to be inlined are at the top of their scopeimport
orexport
statements with pathsnull
,undefined
,true
,false
, an integer, or a short real numberPractically speaking this basically means that you can trigger this optimization by just putting the constants you want inlined into a separate file (e.g.
constants.js
) and bundling everything together.These specific conditions are present to avoid esbuild unintentionally causing any behavior changes by inlining constants when the variable reference could potentially be evaluated before being declared. It's possible to identify more cases where constants can be inlined but doing so may require complex call graph analysis so it has not been implemented. Although these specific heuristics may change over time, this general approach to constant inlining should continue to work going forward.
Here's an example:
v0.14.18
Compare Source
Add the
--mangle-cache=
feature (#1977)This release adds a cache API for the newly-released
--mangle-props=
feature. When enabled, all mangled property renamings are recorded in the cache during the initial build. Subsequent builds reuse the renamings stored in the cache and add additional renamings for any newly-added properties. This has a few consequences:You can customize what mangled properties are renamed to by editing the cache before passing it to esbuild (the cache is a map of the original name to the mangled name).
The cache serves as a list of all properties that were mangled. You can easily scan it to see if there are any unexpected property renamings.
You can disable mangling for individual properties by setting the renamed value to
false
instead of to a string. This is similar to the--reserve-props=
setting but on a per-property basis.You can ensure consistent renaming between builds (e.g. a main-thread file and a web worker, or a library and a plugin). Without this feature, each build would do an independent renaming operation and the mangled property names likely wouldn't be consistent.
Here's how to use it:
CLI
JS API
Go API
The above code would do something like the following:
Add
opera
andie
as possible target environmentsYou can now target Opera and/or Internet Explorer using the
--target=
setting. For example,--target=opera45,ie9
targets Opera 45 and Internet Explorer 9. This change does not add any additional features to esbuild's code transformation pipeline to transform newer syntax so that it works in Internet Explorer. It just adds information about what features are supported in these browsers to esbuild's internal feature compatibility table.Minify
typeof x !== 'undefined'
totypeof x < 'u'
This release introduces a small improvement for code that does a lot of
typeof
checks againstundefined
:This transformation is only active when minification is enabled, and is disabled if the language target is set lower than ES2020 or if Internet Explorer is set as a target environment. Before ES2020, implementations were allowed to return non-standard values from the
typeof
operator for a few objects. Internet Explorer took advantage of this to sometimes return the string'unknown'
instead of'undefined'
. But this has been removed from the specification and Internet Explorer was the only engine to do this, so this minification is valid for code that does not need to target Internet Explorer.v0.14.17
Compare Source
Attempt to fix an install script issue on Ubuntu Linux (#1711)
There have been some reports of esbuild failing to install on Ubuntu Linux for a while now. I haven't been able to reproduce this myself due to lack of reproduction instructions until today, when I learned that the issue only happens when you install node from the Snap Store instead of downloading the official version of node.
The problem appears to be that when node is installed from the Snap Store, install scripts are run with stderr not being writable? This then appears to cause a problem for esbuild's install script when it uses
execFileSync
to validate that the esbuild binary is working correctly. This throws the errorEACCES: permission denied, write
even though this particular command never writes to stderr.Node's documentation says that stderr for
execFileSync
defaults to that of the parent process. Forcing it to'pipe'
instead appears to fix the issue, although I still don't fully understand what's happening or why. I'm publishing this small change regardless to see if it fixes this install script edge case.Avoid a syntax error due to
--mangle-props=.
andsuper()
(#1976)This release fixes an issue where passing
--mangle-props=.
(i.e. telling esbuild to mangle every single property) caused a syntax error with code like this:The problem was that
constructor
was being renamed to another method, which then made it no longer a constructor, which meant thatsuper()
was now a syntax error. I have added a workaround that avoids renaming any property namedconstructor
so that esbuild doesn't generate a syntax error here.Despite this fix, I highly recommend not using
--mangle-props=.
because your code will almost certainly be broken. You will have to manually add every single property that you don't want mangled to--reserve-props=
which is an excessive maintenance burden (e.g. reserveparse
to useJSON.parse
). Instead I recommend using a common pattern for all properties you intend to be mangled that is unlikely to appear in the APIs you use such as "ends in an underscore." This is an opt-in approach instead of an opt-out approach. It also makes it obvious when reading the code which properties will be mangled and which ones won't be.v0.14.16
Compare Source
Support property name mangling with some TypeScript syntax features
The newly-released
--mangle-props=
feature previously only affected JavaScript syntax features. This release adds support for using mangle props with certain TypeScript syntax features:TypeScript parameter properties
Parameter properties are a TypeScript-only shorthand way of initializing a class field directly from the constructor argument list. Previously parameter properties were not treated as properties to be mangled. They should now be handled correctly:
TypeScript namespaces
Namespaces are a TypeScript-only way to add properties to an object. Previously exported namespace members were not treated as properties to be mangled. They should now be handled correctly:
Fix property name mangling for lowered class fields
This release fixes a compiler crash with
--mangle-props=
and class fields that need to be transformed to older versions of JavaScript. The problem was that doing this is an unusual case where the mangled property name must be represented as a string instead of as a property name, which previously wasn't implemented. This case should now work correctly:v0.14.15
Compare Source
Add property name mangling with
--mangle-props=
(#218)This release introduces property name mangling, which is similar to an existing feature from the popular UglifyJS and Terser JavaScript minifiers. This setting lets you pass a regular expression to esbuild to tell esbuild to automatically rename all properties that match this regular expression. It's useful when you want to minify certain property names in your code either to make the generated code smaller or to somewhat obfuscate your code's intent.
Here's an example that uses the regular expression `_
This PR contains the following updates:
0.11.19
->0.14.25
to mangle all properties ending in an underscore, such as
foo_
:This PR contains the following updates:
0.11.19
->0.14.25
(i.e. must end in a non-underscore followed by an underscore).
This PR contains the following updates:
0.11.19
->0.14.25
to reserve all properties that start and end with two underscores, such as
__foo__
:Mark esbuild as supporting node v12+ (#1970)
Someone requested that esbuild populate the
engines.node
field inpackage.json
. This release adds the following to eachpackage.json
file that esbuild publishes:This was chosen because it's the oldest version of node that's currently still receiving support from the node team, and so is the oldest version of node that esbuild supports: https://nodejs.org/en/about/releases/.
Remove error recovery for invalid
//
comments in CSS (#1965)Previously esbuild treated
//
as a comment in CSS and generated a warning, even though comments in CSS use/* ... */
instead. This allowed you to run esbuild on CSS intended for certain CSS preprocessors that support single-line comments.However, some people are changing from another build tool to esbuild and have a code base that relies on
//
being preserved even though it's nonsense CSS and causes the entire surrounding rule to be discarded by the browser. Presumably this nonsense CSS ended up there at some point due to an incorrectly-configured build pipeline and the site now relies on that entire rule being discarded. If esbuild interprets//
as a comment, it could cause the rule to no longer be discarded or even cause something else to happen.With this release, esbuild no longer treats
//
as a comment in CSS. It still warns about it but now passes it through unmodified. This means it's no longer possible to run esbuild on CSS code containing single-line comments but it means that esbuild's behavior regarding these nonsensical CSS rules more accurately represents what happens in a browser.v0.14.14
Compare Source
Fix bug with filename hashes and the
file
loader (#1957)This release fixes a bug where if a file name template has the
[hash]
placeholder (either--entry-names=
or--chunk-names=
), the hash that esbuild generates didn't include the content of the string generated by thefile
loader. Importing a file with thefile
loader causes the imported file to be copied to the output directory and causes the imported value to be the relative path from the output JS file to that copied file. This bug meant that if the--asset-names=
setting also contained[hash]
and the file loaded with thefile
loader was changed, the hash in the copied file name would change but the hash of the JS file would not change, which could potentially result in a stale JS file being loaded. Now the hash of the JS file will be changed too which fixes the reload issue.Prefer the
import
condition for entry points (#1956)The
exports
field inpackage.json
maps package subpaths to file paths. The mapping can be conditional, which lets it vary in different situations. For example, you can have animport
condition that applies when the subpath originated from a JS import statement, and arequire
condition that applies when the subpath originated from a JS require call. These are supposed to be mutually exclusive according to the specification: https://nodejs.org/api/packages.html#conditional-exports.However, there's a situation with esbuild where it's not immediately obvious which one should be applied: when a package name is specified as an entry point. For example, this can happen if you do
esbuild --bundle some-pkg
on the command line. In this situationsome-pkg
does not originate from either a JS import statement or a JS require call. Previously esbuild just didn't apply theimport
orrequire
conditions. But that could result in path resolution failure if the package doesn't provide a back-updefault
condition, as is the case with theis-plain-object
package.Starting with this release, esbuild will now use the
import
condition in this case. This appears to be how Webpack and Rollup handle this situation so this change makes esbuild consistent with other tools in the ecosystem. Parcel (the other major bundler) just doesn't handle this case at all so esbuild's behavior is not at odds with Parcel's behavior here.Make parsing of invalid
@keyframes
rules more robust (#1959)This improves esbuild's parsing of certain malformed
@keyframes
rules to avoid them affecting the following rule. This fix only affects invalid CSS files, and does not change any behavior for files containing valid CSS. Here's an example of the fix:v0.14.13
Compare Source
Be more consistent about external paths (#619)
The rules for marking paths as external using
--external:
grew over time as more special-cases were added. This release reworks the internal representation to be more straightforward and robust. A side effect is that wildcard patterns can now match post-resolve paths in addition to pre-resolve paths. Specifically you can now do--external:./node_modules/*
to mark all files in the./node_modules/
directory as external.This is the updated logic:
Before path resolution begins, import paths are checked against everything passed via an
--external:
flag. In addition, if something looks like a package path (i.e. doesn't start with/
or./
or../
), import paths are checked to see if they have that package path as a path prefix (so--external:@​foo/bar
matches the import path@foo/bar/baz
).After path resolution ends, the absolute paths are checked against everything passed via
--external:
that doesn't look like a package path (i.e. that starts with/
or./
or../
). But before checking, the pattern is transformed to be relative to the current working directory.Attempt to explain why esbuild can't run (#1819)
People sometimes try to install esbuild on one OS and then copy the
node_modules
directory over to another OS without reinstalling. This works with JavaScript code but doesn't work with esbuild because esbuild is a native binary executable. This release attempts to offer a helpful error message when this happens. It looks like this:v0.14.12
Compare Source
Ignore invalid
@import
rules in CSS (#1946)In CSS,
@import
rules must come first before any other kind of rule (except for@charset
rules). Previously esbuild would warn about incorrectly ordered@import
rules and then hoist them to the top of the file. This broke people who wrote invalid@import
rules in the middle of their files and then relied on them being ignored. With this release, esbuild will now ignore invalid@import
rules and pass them through unmodified. This more accurately follows the CSS specification. Note that this behavior differs from other tools like Parcel, which does hoist CSS@import
rules.Print invalid CSS differently (#1947)
This changes how esbuild prints nested
@import
statements that are missing a trailing;
, which is invalid CSS. The result is still partially invalid CSS, but now printed in a better-looking way:Warn about CSS nesting syntax (#1945)
There's a proposed CSS syntax for nesting rules using the
&
selector, but it's not currently implemented in any browser. Previously esbuild silently passed the syntax through untransformed. With this release, esbuild will now warn when you use nesting syntax with a--target=
setting that includes a browser.Warn about
}
and>
inside JSX elementsThe
}
and>
characters are invalid inside JSX elements according to the JSX specification because they commonly result from typos like these that are hard to catch in code reviews:The TypeScript compiler already treats this as an error, so esbuild now treats this as an error in TypeScript files too. That looks like this:
Babel doesn't yet treat this as an error, so esbuild only warns about these characters in JavaScript files for now. Babel 8 treats this as an error but Babel 8 hasn't been released yet. If you see this warning, I recommend fixing the invalid JSX syntax because it will become an error in the future.
Warn about basic CSS property typos
This release now generates a warning if you use a CSS property that is one character off from a known CSS property:
v0.14.11
Compare Source
Fix a bug with enum inlining (#1903)
The new TypeScript enum inlining behavior had a bug where it worked correctly if you used
export enum Foo
but not if you usedenum Foo
and then laterexport { Foo }
. This release fixes the bug so enum inlining now works correctly in this case.Warn about
module.exports.foo = ...
in ESM (#1907)The
module
variable is treated as a global variable reference instead of as a CommonJS module reference in ESM code, which can cause problems for people that try to use both CommonJS and ESM exports in the same file. There has been a warning about this since version 0.14.9. However, the warning only covered cases likeexports.foo = bar
andmodule.exports = bar
but notmodule.exports.foo = bar
. This last case is now handled;Enable esbuild's CLI with Deno (#1913)
This release allows you to use Deno as an esbuild installer, without also needing to use esbuild's JavaScript API. You can now use esbuild's CLI with Deno:
v0.14.10
Compare Source
Enable tree shaking of classes with lowered static fields (#175)
If the configured target environment doesn't support static class fields, they are converted into a call to esbuild's
__publicField
function instead. However, esbuild's tree-shaking pass treated this call as a side effect, which meant that all classes with static fields were ineligible for tree shaking. This release fixes the problem by explicitly ignoring calls to the__publicField
function during tree shaking side-effect determination. Tree shaking is now enabled for these classes:Treat
--define:foo=undefined
as an undefined literal instead of an identifier (#1407)References to the global variable
undefined
are automatically replaced with the literal value for undefined, which appears asvoid 0
when printed. This allows for additional optimizations such as collapsingundefined ?? bar
into justbar
. However, this substitution was not done for values specified via--define:
. As a result, esbuild could potentially miss out on certain optimizations in these cases. With this rConfiguration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.