This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
⚠ Artifact update problemRenovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is. ♻ Renovate will retry this branch, including artifacts, only when one of the following happens:
The artifact failure details are included below: File name: package-lock.json
|
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
November 21, 2022 16:08
d22bbf1
to
16d850f
Compare
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
November 21, 2022 21:54
16d850f
to
e1c3f73
Compare
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
November 24, 2022 06:29
e1c3f73
to
598e08c
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.15.14
Update dependency esbuild to v0.15.15
Nov 24, 2022
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
November 30, 2022 18:01
598e08c
to
d807476
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.15.15
Update dependency esbuild to v0.15.16
Nov 30, 2022
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
December 7, 2022 03:50
d807476
to
0cb8740
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.15.16
Update dependency esbuild to v0.15.17
Dec 7, 2022
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
December 8, 2022 03:36
0cb8740
to
cecb482
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.15.17
Update dependency esbuild to v0.15.18
Dec 8, 2022
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
December 9, 2022 21:30
cecb482
to
a4a1178
Compare
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
December 10, 2022 04:47
a4a1178
to
637da48
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.15.18
Update dependency esbuild to v0.16.0
Dec 10, 2022
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
December 10, 2022 06:35
637da48
to
43097c2
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.16.0
Update dependency esbuild to v0.16.1
Dec 10, 2022
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
December 11, 2022 07:20
43097c2
to
a44512d
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.16.1
Update dependency esbuild to v0.16.2
Dec 11, 2022
renovate
bot
changed the title
Update dependency esbuild to v0.16.15
Update dependency esbuild to v0.16.16
Jan 12, 2023
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 14, 2023 23:41
421b4c8
to
bef2e40
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.16.16
Update dependency esbuild to v0.16.17
Jan 14, 2023
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 16, 2023 13:44
bef2e40
to
d5707c5
Compare
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 16, 2023 17:39
d5707c5
to
b646fda
Compare
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 17, 2023 04:49
b646fda
to
81ab665
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.16.17
Update dependency esbuild to v0.17.0
Jan 17, 2023
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 17, 2023 12:34
81ab665
to
33af658
Compare
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 19, 2023 18:48
33af658
to
9853104
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.17.0
Update dependency esbuild to v0.17.1
Jan 19, 2023
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 20, 2023 08:31
9853104
to
95d9cd4
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.17.1
Update dependency esbuild to v0.17.2
Jan 20, 2023
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 21, 2023 20:29
95d9cd4
to
971d606
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.17.2
Update dependency esbuild to v0.17.3
Jan 21, 2023
renovate
bot
force-pushed
the
renovate/esbuild-0.x
branch
from
January 25, 2023 06:28
971d606
to
fd367eb
Compare
renovate
bot
changed the title
Update dependency esbuild to v0.17.3
Update dependency esbuild to v0.17.4
Jan 25, 2023
Renovate Ignore NotificationAs this PR has been closed unmerged, Renovate will now ignore this update (0.17.4). You will still receive a PR once a newer version is released, so if you wish to permanently ignore this dependency, please add it to the If this PR was closed by mistake or you changed your mind, you can simply rename this PR and you will soon get a fresh replacement PR opened. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.15.13
->0.17.4
Release Notes
evanw/esbuild
v0.17.4
Compare Source
Implement HTTP
HEAD
requests in serve mode (#2851)Previously esbuild's serve mode only responded to HTTP
GET
requests. With this release, esbuild's serve mode will also respond to HTTPHEAD
requests, which are just like HTTPGET
requests except that the body of the response is omitted.Permit top-level await in dead code branches (#2853)
Adding top-level await to a file has a few consequences with esbuild:
module
andexports
for exports and also enables strict mode, which disables certain syntax and changes how function hoisting works (among other things).require()
on this file or on any file that imports this file (even indirectly), since therequire()
function doesn't return a promise and so can't represent top-level await.This release relaxes these rules slightly: rules 2 and 3 will now no longer apply when esbuild has identified the code branch as dead code, such as when it's behind an
if (false)
check. This should make it possible to use esbuild to convert code into different output formats that only uses top-level await conditionally. This release does not relax rule 1. Top-level await will still cause esbuild to unconditionally consider the input module format to be ESM, even when the top-levelawait
is in a dead code branch. This is necessary because whether the input format is ESM or not affects the whole file, not just the dead code branch.Fix entry points where the entire file name is the extension (#2861)
Previously if you passed esbuild an entry point where the file extension is the entire file name, esbuild would use the parent directory name to derive the name of the output file. For example, if you passed esbuild a file
./src/.ts
then the output name would besrc.js
. This bug happened because esbuild first strips the file extension to get./src/
and then joins the path with the working directory to get the absolute path (e.g.join("/working/dir", "./src/")
gives/working/dir/src
). However, the join operation also canonicalizes the path which strips the trailing/
. Later esbuild uses the "base name" operation to extract the name of the output file. Since there is no trailing/
, esbuild returns"src"
as the base name instead of""
, which causes esbuild to incorrectly include the directory name in the output file name. This release fixes this bug by deferring the stripping of the file extension until after all path manipulations have been completed. So now the file./src/.ts
will generate an output file named.js
.Support replacing property access expressions with inject
At a high level, this change means the
inject
feature can now replace all of the same kinds of names as thedefine
feature. Soinject
is basically now a more powerful version ofdefine
, instead of previously only being able to do some of the things thatdefine
could do.Soem background is necessary to understand this change if you aren't already familiar with the
inject
feature. Theinject
feature lets you replace references to global variable with a shim. It works like this:inject
featureFor example, if you inject the following file using
--inject:./injected.js
:Then esbuild will replace all references to
process
with theprocessShim
variable, which will causeprocess.cwd()
to return'/'
. This feature is sort of abusing the ESM export alias syntax to specify the mapping of global variables to shims. But esbuild works this way because using this syntax for that purpose is convenient and terse.However, if you wanted to replace a property access expression, the process was more complicated and not as nice. You would have to:
inject
featuredefine
feature to map the property access expression to the random name you made in step 2For example, if you inject the following file using
--inject:./injected2.js --define:process.cwd=someRandomName
:Then esbuild will replace all references to
process.cwd
with thecwdShim
variable, which will also causeprocess.cwd()
to return'/'
(but which this time will not mess with other references toprocess
, which might be desirable).With this release, using the inject feature to replace a property access expression is now as simple as using it to replace an identifier. You can now use JavaScript's "arbitrary module namespace identifier names" feature to specify the property access expression directly using a string literal. For example, if you inject the following file using
--inject:./injected3.js
:Then esbuild will now replace all references to
process.cwd
with thecwdShim
variable, which will also causeprocess.cwd()
to return'/'
(but which will also not mess with other references toprocess
).In addition to inserting a shim for a global variable that doesn't exist, another use case is replacing references to static methods on global objects with cached versions to both minify them better and to make access to them potentially faster. For example:
v0.17.3
Compare Source
Fix incorrect CSS minification for certain rules (#2838)
Certain rules such as
@media
could previously be minified incorrectly. Due to a typo in the duplicate rule checker, two known@
-rules that share the same hash code were incorrectly considered to be equal. This problem was made worse by the rule hashing code considering two unknown declarations (such as CSS variables) to have the same hash code, which also isn't optimal from a performance perspective. Both of these issues have been fixed:v0.17.2
Compare Source
Add
onDispose
to the plugin API (#2140, #2205)If your plugin wants to perform some cleanup after it's no longer going to be used, you can now use the
onDispose
API to register a callback for cleanup-related tasks. For example, if a plugin starts a long-running child process then it may want to terminate that process when the plugin is discarded. Previously there was no way to do this. Here's an example:These
onDispose
callbacks will be called after everybuild()
call regardless of whether the build failed or not as well as after the firstdispose()
call on a given build context.v0.17.1
Compare Source
Make it possible to cancel a build (#2725)
The context object introduced in version 0.17.0 has a new
cancel()
method. You can use it to cancel a long-running build so that you can start a new one without needing to wait for the previous one to finish. When this happens, the previous build should always have at least one error and have no output files (i.e. it will be a failed build).Using it might look something like this:
JS:
Go:
This API is a quick implementation and isn't maximally efficient, so the build may continue to do some work for a little bit before stopping. For example, I have added stop points between each top-level phase of the bundler and in the main module graph traversal loop, but I haven't added fine-grained stop points within the internals of the linker. How quickly esbuild stops can be improved in future releases. This means you'll want to wait for
cancel()
and/or the previousrebuild()
to finish (i.e. await the returned promise in JavaScript) before starting a new build, otherwiserebuild()
will give you the just-canceled build that still hasn't ended yet. Note thatonEnd
callbacks will still be run regardless of whether or not the build was canceled.Fix server-sent events without
servedir
(#2827)The server-sent events for live reload were incorrectly using
servedir
to calculate the path to modified output files. This means events couldn't be sent whenservedir
wasn't specified. This release uses the internal output directory (which is always present) instead ofservedir
(which might be omitted), so live reload should now work whenservedir
is not specified.Custom entry point output paths now work with the
copy
loader (#2828)Entry points can optionally provide custom output paths to change the path of the generated output file. For example,
esbuild foo=abc.js bar=xyz.js --outdir=out
generates the filesout/foo.js
andout/bar.js
. However, this previously didn't work when using thecopy
loader due to an oversight. This bug has been fixed. For example, you can now doesbuild foo=abc.html bar=xyz.html --outdir=out --loader:.html=copy
to generate the filesout/foo.html
andout/bar.html
.The JS API can now take an array of objects (#2828)
Previously it was not possible to specify two entry points with the same custom output path using the JS API, although it was possible to do this with the Go API and the CLI. This will not cause a collision if both entry points use different extensions (e.g. if one uses
.js
and the other uses.css
). You can now pass the JS API an array of objects to work around this API limitation:v0.17.0
Compare Source
This release deliberately contains backwards-incompatible changes. To avoid automatically picking up releases like this, you should either be pinning the exact version of
esbuild
in yourpackage.json
file (recommended) or be using a version range syntax that only accepts patch upgrades such as^0.16.0
or~0.16.0
. See npm's documentation about semver for more information.At a high level, the breaking changes in this release fix some long-standing issues with the design of esbuild's incremental, watch, and serve APIs. This release also introduces some exciting new features such as live reloading. In detail:
Move everything related to incremental builds to a new
context
API (#1037, #1606, #2280, #2418)This change removes the
incremental
andwatch
options as well as theserve()
method, and introduces a newcontext()
method. The context method takes the same arguments as thebuild()
method but only validates its arguments and does not do an initial build. Instead, builds can be triggered using therebuild()
,watch()
, andserve()
methods on the returned context object. The new context API looks like this:The switch to the context API solves a major issue with the previous API which is that if the initial build fails, a promise is thrown in JavaScript which prevents you from accessing the returned result object. That prevented you from setting up long-running operations such as watch mode when the initial build contained errors. It also makes tearing down incremental builds simpler as there is now a single way to do it instead of three separate ways.
In addition, this release also makes some subtle changes to how incremental builds work. Previously every call to
rebuild()
started a new build. If you weren't careful, then builds could actually overlap. This doesn't cause any problems with esbuild itself, but could potentially cause problems with plugins (esbuild doesn't even give you a way to identify which overlapping build a given plugin callback is running on). Overlapping builds also arguably aren't useful, or at least aren't useful enough to justify the confusion and complexity that they bring. With this release, there is now only ever a single active build per context. Callingrebuild()
before the previous rebuild has finished now "merges" with the existing rebuild instead of starting a new build.Allow using
watch
andserve
together (#805, #1650, #2576)Previously it was not possible to use watch mode and serve mode together. The rationale was that watch mode is one way of automatically rebuilding your project and serve mode is another (since serve mode automatically rebuilds on every request). However, people want to combine these two features to make "live reloading" where the browser automatically reloads the page when files are changed on the file system.
This release now allows you to use these two features together. You can only call the
watch()
andserve()
APIs once each per context, but if you call them together on the same context then esbuild will automatically rebuild both when files on the file system are changed and when the server serves a request.Support "live reloading" through server-sent events (#802)
Server-sent events are a simple way to pass one-directional messages asynchronously from the server to the client. Serve mode now provides a
/esbuild
endpoint with anchange
event that triggers every time esbuild's output changes. So you can now implement simple "live reloading" (i.e. reloading the page when a file is edited and saved) like this:The event payload is a JSON object with the following shape:
This JSON should also enable more complex live reloading scenarios. For example, the following code hot-swaps changed CSS
<link>
tags in place without reloading the page (but still reloads when there are other types of changes):Implementing live reloading like this has a few known caveats:
These events only trigger when esbuild's output changes. They do not trigger when files unrelated to the build being watched are changed. If your HTML file references other files that esbuild doesn't know about and those files are changed, you can either manually reload the page or you can implement your own live reloading infrastructure instead of using esbuild's built-in behavior.
The
EventSource
API is supposed to automatically reconnect for you. However, there's a bug in Firefox that breaks this if the server is ever temporarily unreachable: https://bugzilla.mozilla.org/show_bug.cgi?id=1809332. Workarounds are to use any other browser, to manually reload the page if this happens, or to write more complicated code that manually closes and re-creates theEventSource
object if there is a connection error. I'm hopeful that this bug will be fixed.Browser vendors have decided to not implement HTTP/2 without TLS. This means that each
/esbuild
event source will take up one of your precious 6 simultaneous per-domain HTTP/1.1 connections. So if you open more than six HTTP tabs that use this live-reloading technique, you will be unable to use live reloading in some of those tabs (and other things will likely also break). The workaround is to enable HTTPS, which is now possible to do in esbuild itself (see below).Add built-in support for HTTPS (#2169)
You can now tell esbuild's built-in development server to use HTTPS instead of HTTP. This is sometimes necessary because browser vendors have started making modern web features unavailable to HTTP websites. Previously you had to put a proxy in front of esbuild to enable HTTPS since esbuild's development server only supported HTTP. But with this release, you can now enable HTTPS with esbuild without an additional proxy.
To enable HTTPS with esbuild:
Generate a self-signed certificate. There are many ways to do this. Here's one way, assuming you have
openssl
installed:Add
--keyfile=key.pem
and--certfile=cert.pem
to your esbuild development server commandClick past the scary warning in your browser when you load your page
If you have more complex needs than this, you can still put a proxy in front of esbuild and use that for HTTPS instead. Note that if you see the message "Client sent an HTTP request to an HTTPS server" when you load your page, then you are using the incorrect protocol. Replace
http://
withhttps://
in your browser's URL bar.Keep in mind that esbuild's HTTPS support has nothing to do with security. The only reason esbuild now supports HTTPS is because browsers have made it impossible to do local development with certain modern web features without jumping through these extra hoops. Please do not use esbuild's development server for anything that needs to be secure. It's only intended for local development and no considerations have been made for production environments whatsoever.
Better support copying
index.html
into the output directory (#621, #1771)Right now esbuild only supports JavaScript and CSS as first-class content types. Previously this meant that if you were building a website with a HTML file, a JavaScript file, and a CSS file, you could use esbuild to build the JavaScript file and the CSS file into the output directory but not to copy the HTML file into the output directory. You needed a separate
cp
command for that.Or so I thought. It turns out that the
copy
loader added in version 0.14.44 of esbuild is sufficient to have esbuild copy the HTML file into the output directory as well. You can add something likeindex.html --loader:.html=copy
and esbuild will copyindex.html
into the output directory for you. The benefits of this are a) you don't need a separatecp
command and b) theindex.html
file will automatically be re-copied when esbuild is in watch mode and the contents ofindex.html
are edited. This also goes for other non-HTML file types that you might want to copy.This pretty much already worked. The one thing that didn't work was that esbuild's built-in development server previously only supported implicitly loading
index.html
(e.g. loading/about/index.html
when you visit/about/
) whenindex.html
existed on the file system. Previously esbuild didn't support implicitly loadingindex.html
if it was a build result. That bug has been fixed with this release so it should now be practical to use thecopy
loader to do this.Fix
onEnd
not being called in serve mode (#1384)Previous releases had a bug where plugin
onEnd
callbacks weren't called when using the top-levelserve()
API. This API no longer exists and the internals have been reimplemented such thatonEnd
callbacks should now always be called at the end of every build.Incremental builds now write out build results differently (#2104)
Previously build results were always written out after every build. However, this could cause the output directory to fill up with files from old builds if code splitting was enabled, since the file names for code splitting chunks contain content hashes and old files were not deleted.
With this release, incremental builds in esbuild will now delete old output files from previous builds that are no longer relevant. Subsequent incremental builds will also no longer overwrite output files whose contents haven't changed since the previous incremental build.
The
onRebuild
watch mode callback was removed (#980, #2499)Previously watch mode accepted an
onRebuild
callback which was called whenever watch mode rebuilt something. This was not great in practice because if you are running code after a build, you likely want that code to run after every build, not just after the second and subsequent builds. This release removes option to provide anonRebuild
callback. You can create a plugin with anonEnd
callback instead. TheonEnd
plugin API already exists, and is a way to run some code after every build.You can now return errors from
onEnd
(#2625)It's now possible to add additional build errors and/or warnings to the current build from within your
onEnd
callback by returning them in an array. This is identical to how theonStart
callback already works. The evaluation ofonEnd
callbacks have been moved around a bit internally to make this possible.Note that the build will only fail (i.e. reject the promise) if the additional errors are returned from
onEnd
. Adding additional errors to the result object that's passed toonEnd
won't affect esbuild's behavior at all.Print URLs and ports from the Go and JS APIs (#2393)
Previously esbuild's CLI printed out something like this when serve mode is active:
The CLI still does this, but now the JS and Go serve mode APIs will do this too. This only happens when the log level is set to
verbose
,debug
, orinfo
but not when it's set towarning
,error
, orsilent
.Upgrade guide for existing code:
Rebuild (a.k.a. incremental build):
Before:
After:
Previously the first build was done differently than subsequent builds. Now both the first build and subsequent builds are done using the same API.
Serve:
Before:
After:
Watch:
Before:
After:
Watch with
onRebuild
:Before:
After:
The
onRebuild
function has now been removed. The replacement is to make a plugin with anonEnd
callback.Previously
onRebuild
did not fire for the first build (only for subsequent builds). This was usually problematic, so usingonEnd
instead ofonRebuild
is likely less error-prone. But if you need to emulate the old behavior ofonRebuild
that ignores the first build, then you'll need to manually count and ignore the first build in your plugin (as demonstrated above).Notice how all of these API calls are now done off the new context object. You should now be able to use all three kinds of incremental builds (
rebuild
,serve
, andwatch
) together on the same context object. Also notice how callingdispose
on the context is now the common way to discard the context and free resources in all of these situations.v0.16.17
Compare Source
Fix additional comment-related regressions (#2814)
This release fixes more edge cases where the new comment preservation behavior that was added in 0.16.14 could introduce syntax errors. Specifically:
These cases caused esbuild to generate code with a syntax error in version 0.16.14 or above. These bugs have now been fixed.
v0.16.16
Compare Source
Fix a regression caused by comment preservation (#2805)
The new comment preservation behavior that was added in 0.16.14 introduced a regression where comments in certain locations could cause esbuild to omit certain necessary parentheses in the output. The outermost parentheses were incorrectly removed for the following syntax forms, which then introduced syntax errors:
This regression has been fixed.
v0.16.15
Compare Source
Add
format
to input files in the JSON metafile dataWhen
--metafile
is enabled, input files may now have an additionalformat
field that indicates the export format used by this file. When present, the value will either becjs
for CommonJS-style exports oresm
for ESM-style exports. This can be useful in bundle analysis.For example, esbuild's new Bundle Size Analyzer now uses this information to visualize whether ESM or CommonJS was used for each directory and file of source code (click on the CJS/ESM bar at the top).
This information is helpful when trying to reduce the size of your bundle. Using the ESM variant of a dependency instead of the CommonJS variant always results in a faster and smaller bundle because it omits CommonJS wrappers, and also may result in better tree-shaking as it allows esbuild to perform tree-shaking at the statement level instead of the module level.
Fix a bundling edge case with dynamic import (#2793)
This release fixes a bug where esbuild's bundler could produce incorrect output. The problematic edge case involves the entry point importing itself using a dynamic
import()
expression in an imported file, like this:Remove new type syntax from type declarations in the
esbuild
package (#2798)Previously you needed to use TypeScript 4.3 or newer when using the
esbuild
package from TypeScript code due to the use of a getter in an interface innode_modules/esbuild/lib/main.d.ts
. This release removes this newer syntax to allow people with versions of TypeScript as far back as TypeScript 3.5 to use this latest version of theesbuild
package. Here is change that was made to esbuild's type declarations:v0.16.14
Compare Source
Preserve some comments in expressions (#2721)
Various tools give semantic meaning to comments embedded inside of expressions. For example, Webpack and Vite have special "magic comments" that can be used to affect code splitting behavior:
Since esbuild can be used as a preprocessor for these tools (e.g. to strip TypeScript types), it can be problematic if esbuild doesn't do additional work to try to retain these comments. Previously esbuild special-cased Webpack comments in these specific locations in the AST. But Vite would now like to use similar comments, and likely other tools as well.
So with this release, esbuild now will attempt to preserve some comments inside of expressions in more situations than before. This behavior is mainly intended to preserve these special "magic comments" that are meant for other tools to consume, although esbuild will no longer only preserve Webpack-specific comments so it should now be tool-agnostic. There is no guarantee that all such comments will be preserved (especially when
--minify-syntax
is enabled). So this change does not mean that esbuild is now usable as a code formatter. In particular comment preservation is more likely to happen with leading comments than with trailing comments. You should put comments that you want to be preserved before the relevant expression instead of after it. Also note that this change does not retain any more statement-level comments than before (i.e. comments not embedded inside of expressions). Comment preservation is not enabled when--minify-whitespace
is enabled (which is automatically enabled when you use--minify
).v0.16.13
Compare Source
Publish a new bundle visualization tool
While esbuild provides bundle metadata via the
--metafile
flag, previously esbuild left analysis of it completely up to third-party tools (well, outside of the rudimentary--analyze
flag). However, the esbuild website now has a built-in bundle visualization tool:You can pass
--metafile
to esbuild to output bundle metadata, then upload that JSON file to this tool to visualize your bundle. This is helpful for answering questions such as:I'm publishing this tool because I think esbuild should provide some answer to "how do I visualize my bundle" without requiring people to reach for third-party tools. At the moment the tool offers two types of visualizations: a radial "sunburst chart" and a linear "flame chart". They serve slightly different but overlapping use cases (e.g. the sunburst chart is more keyboard-accessible while the flame chart is easier with the mouse). This tool may continue to evolve over time.
Fix
--metafile
and--mangle-cache
with--watch
(#1357)The CLI calls the Go API and then also writes out the metafile and/or mangle cache JSON files if those features are enabled. This extra step is necessary because these files are returned by the Go API as in-memory strings. However, this extra step accidentally didn't happen for all builds after the initial build when watch mode was enabled. This behavior used to work but it was broken in version 0.14.18 by the introduction of the mangle cache feature. This release fixes the combination of these features, so the metafile and mangle cache features should now work with watch mode. This behavior was only broken for the CLI, not for the JS or Go APIs.
Add an
original
field to the metafileThe metadata file JSON now has an additional field: each import in an input file now contains the pre-resolved path in the
original
field in addition to the post-resolved path in thepath
field. This means it's now possible to run certain additional analysis over your bundle. For example, you should be able to use this to detect when the same package subpath is represented multiple times in the bundle, either because multiple versions of a package were bundled or because a package is experiencing the dual-package hazard.v0.16.12
Compare Source
Loader defaults to
js
for extensionless files (#2776)Certain packages contain files without an extension. For example, the
yargs
package contains the fileyargs/yargs
which has no extension. Node, Webpack, and Parcel can all understand code that importsyargs/yargs
because they assume that the file is JavaScript. However, esbuild was previously unable to understand this code because it relies on the file extension to tell it how to interpret the file. With this release, esbuild will now assume files without an extension are JavaScript files. This can be customized by setting the loader for""
(the empty string, representing files without an extension) to another loader. For example, if you want files without an extension to be treated as CSS instead, you can do that like this:CLI:
JS:
Go:
In addition, the
"type"
field inpackage.json
files now only applies to files with an explicit.js
,.jsx
,.ts
, or.tsx
extension. Previously it was incorrectly applied by esbuild to all files that had an extension other than.mjs
,.mts
,.cjs
, or.cts
including extensionless files. So for example an extensionless file in a"type": "module"
package is now treated as CommonJS instead of ESM.v0.16.11
Compare Source
Avoid a syntax error in the presence of direct
eval
(#2761)The behavior of nested
function
declarations in JavaScript depends on whether the code is run in strict mode or not. It would be problematic if esbuild preserved nestedfunction
declarations in its output because then the behavior would depend on whether the output was run in strict mode or not instead of respecting the strict mode behavior of the original source code. To avoid this, esbuild transforms nestedfunction
declarations to preserve the intended behavior of the original source code regardless of whether the output is run in strict mode or not:In the above example, the original code should print
true false true
because it's not run in strict mode (it doesn't contain"use strict"
and is not an ES module). The code that esbuild generates has been transformed such that it printstrue false true
regardless of whether it's run in strict mode or not.However, this transformation is impossible if the code contains direct
eval
because directeval
"poisons" all containing scopes by preventing anything in those scopes from being renamed. That prevents esbuild from splitting up accesses tofoo
into two separate variables with different names. Previously esbuild still did this transformation but with two variables both namedfoo
, which is a syntax error. With this release esbuild will now skip doing this transformation when directeval
is present to avoid generating code with a syntax error. This means that the generated code may no longer behave as intended since the behavior depends on the run-time strict mode setting instead of the strict mode setting present in the original source code. To fix this problem, you will need to remove the use of directeval
.Fix a bundling scenario involving multiple symlinks (#2773, #2774)
This release contains a fix for a bundling scenario involving an import path where multiple path segments are symlinks. Previously esbuild was unable to resolve certain import paths in this scenario, but these import paths should now work starting with this release. This fix was contributed by @onebytegone.
v0.16.10
Compare Source
Change the default "legal comment" behavior again (#2745)
The legal comments feature automatically gathers comments containing
@license
or@preserve
and puts the comments somewhere (either in the generated code or in a separate file). This behavior used to be on by default but was disabled by default in version 0.16.0 because automatically inserting comments is potentially confusing and misleading. These comments can appear to be assigning the copyright of your code to another entity. And this behavior can be especially problematic if it happens automatically by default since you may not even be aware of it happening. For example, if you bundle the TypeScript compiler the preserving legal comments means your source code would contain this comment, which appears to be assigning the copyright of all of your code to Microsoft:However, people have asked for this feature to be re-enabled by default. To resolve the confusion about what these comments are applying to, esbuild's default behavior will now be to attempt to describe which package the comments are coming from. So while this feature has been re-enabled by default, the output will now look something like this instead:
Note that you can still customize this behavior with the
--legal-comments=
flag. For example, you can use--legal-comments=none
to turn this off, or you can use--legal-comments=linked
to put these comments in a separate.LEGAL.txt
file instead.Enable
external
legal comments with the transform API (#2390)Previously esbuild's transform API only supported
none
,inline
, oreof
legal comments. With this release,external
legal comments are now also supported with the transform API. This only applies to the JS and Go APIs, not to the CLI, and looks like this:JS:
Go:
Fix duplicate function declaration edge cases (#2757)
The change in the previous release to forbid duplicate function declarations in certain cases accidentally forbid some edge cases that should have been allowed. Specifically duplicate function declarations are forbidden in nested blocks in strict mode and at the top level of modules, but are allowed when they are declared at the top level of function bodies. This release fixes the regression by re-allowing the last case.
Allow package subpaths with
alias
(#2715)Previously the names passed to the
alias
feature had to be the name of a package (with or without a package scope). With this release, you can now also use thealias
feature with package subpaths. So for example you can now create an alias that substitutes@org/pkg/lib
with something else.v0.16.9
Compare Source
Update to Unicode 15.0.0
The character tables that determine which characters form valid JavaScript identifiers have been updated from Unicode version 14.0.0 to the newly-released Unicode version 15.0.0. I'm not putting an example in the release notes because all of the new characters will likely just show up as little squares since fonts haven't been updated yet. But you can read https://www.unicode.org/versions/Unicode15.0.0/#Summary for more information about the changes.
Disallow duplicate lexically-declared names in nested blocks and in strict mode
In strict mode or in a nested block, it's supposed to be a syntax error to declare two symbols with the same name unless all duplicate entries are either
function
declarations or allvar
declarations. However, esbuild was overly permissive and allowed this when duplicate entries were eitherfunction
declarations orvar
declarations (even if they were mixed). This check has now been made more restrictive to match the JavaScript specification:Add a type declaration for the new
empty
loader (#2755)I forgot to add this in the previous release. It has now been added.
This fix was contributed by @fz6m.
Add support for the
v
flag in regular expression literalsPeople are currently working on adding a
v
flag to JavaScript regular expresions. You can read more about this flag here: https://v8.dev/features/regexp-v-flag. This release adds support for parsing this flag, so esbuild will now no longer consider regular expression literals with this flag to be a syntax error. If the target is set to something other thanesnext
, esbuild will transform regular expression literals containing this flag into anew RegExp()
constructor call so the resulting code doesn't have a syntax error. This enables you to provide a polyfill forRegExp
that implements thev
flag to get your code to work at run-time. While esbuild doesn't typically adopt proposals until they're already shipping in a real JavaScript run-time, I'm adding it now because a) esbuild's implementation doesn't need to change as the proposal evolves, b) this isn't really new syntax since regular expression literals already have flags, and c) esbuild's implementation is a trivial pass-through anyway.Avoid keeping the name of classes with static
name
propertiesThe
--keep-names
property attempts to preserve the original value of thename
property for functions and classes even when identifiers are renamed by the minifier or to avoid a name collision. This is currently done by generating code to assign a string to thename
property on the function or class object. However, this should not be done for classes with a staticname
property since in that case the explicitly-definedname
property overwrites the automatically-generated class name. With this release, esbuild will now no longer attempt to preserve thename
property for classes with a staticname
property.v0.16.8
Compare Source
Allow plugins to resolve injected files (#2754)
Previously paths passed to the
inject
feature were always interpreted as file system paths. This meant thatonResolve
plugins would not be run for them and esbuild's default path resolver would always be used. This meant that theinject
feature couldn't be used in the browser since the browser doesn't have access to a file system. This release runs paths passed toinject
through esbuild's full path resolution pipeline so plugins now have a chance to handle them usingonResolve
callbacks. This makes it possible to write a plugin that makes esbuild'sinject
work in the browser.Add the
empty
loader (#1541, #2753)The new
empty
loader tells esbuild to pretend that a file is empty. So for example--loader:.css=empty
effectively skips all imports of.css
files in JavaScript so that they aren't included in the bundle, sinceimport "./some-empty-file"
in JavaScript doesn't bundle anything. You can also use theempty
loader to remove asset references in CSS files. For example--loader:.png=empty
causes esbuild to replace asset references such asurl(image.png)
withurl()
so that they are no longer included in the resulting style sheet.Fix
</script>
and</style>
escaping for non-default targets (#2748)The change in version 0.16.0 to give control over
</script>
escaping via--supported:inline-script=false
or--supported:inline-script=true
accidentally broke automatic escaping of</script>
when an explicittarget
setting is specified. This release restores the correct automatic escaping of</script>
(which should not depend on whattarget
is set to).Enable the
exports
field withNODE_PATHS
(#2752)Node has a rarely-used feature where you can extend the set of directories that node searches for packages using the
NODE_PATHS
environment variable. While esbuild supports this too, previously it only supported the oldmain
field path resolution but did not support the newexports
field package resolution. This release makes the path resolution rules the same again for bothnode_modules
directories andNODE_PATHS
directories.v0.16.7
Compare Source
Include
file
loader strings in metafile imports (#2731)Bundling a file with the
file
loader copies that file to the output directory and imports a module with the path to the copied file in thedefault
export. Previously when bundling with thefile
loader, there was no reference in the metafile from the JavaScript file containing the path string to the copied file. With this release, there will now be a reference in the metafile in theimports
array with the kindfile-loader
:Fix byte counts in metafile regarding references to other output files (#2071)
Previously files that contained references to other output files had slightly incorrect metadata for the byte counts of input files which contributed to that output file. So for example if
app.js
importsimage.png
using the file loader and esbuild generatesout.js
andimage-LSAMBFUD.png
, the metadata for how many bytes ofout.js
are fromapp.js
was slightly off (the metadata for the byte count ofout.js
was still correct). The reason is because esbuild substitutes the final paths for references between output files toward the end of the build to handle cyclic references, and the byte counts needed to be adjusted as well during the path substitution. This release fixes these byte counts (specifically thebytesInOutput
values).The alias feature now strips a trailing slash ([#2730](https://togithub.com/evanw/esbuild/issu
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, 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 Mend Renovate. View repository job log here.