evanw/esbuild
### [`v0.16.5`](https://togithub.com/evanw/esbuild/blob/HEAD/CHANGELOG.md#0165)
[Compare Source](https://togithub.com/evanw/esbuild/compare/v0.16.4...v0.16.5)
- Make it easy to exclude all packages from a bundle ([#1958](https://togithub.com/evanw/esbuild/issues/1958), [#1975](https://togithub.com/evanw/esbuild/issues/1975), [#2164](https://togithub.com/evanw/esbuild/issues/2164), [#2246](https://togithub.com/evanw/esbuild/issues/2246), [#2542](https://togithub.com/evanw/esbuild/issues/2542))
When bundling for node, it's often necessary to exclude npm packages from the bundle since they weren't designed with esbuild bundling in mind and don't work correctly after being bundled. For example, they may use `__dirname` and run-time file system calls to load files, which doesn't work after bundling with esbuild. Or they may compile a native `.node` extension that has similar expectations about the layout of the file system that are no longer true after bundling (even if the `.node` extension is copied next to the bundle).
The way to get this to work with esbuild is to use the `--external:` flag. For example, the [`fsevents`](https://www.npmjs.com/package/fsevents) package contains a native `.node` extension and shouldn't be bundled. To bundle code that uses it, you can pass `--external:fsevents` to esbuild to exclude it from your bundle. You will then need to ensure that the `fsevents` package is still present when you run your bundle (e.g. by publishing your bundle to npm as a package with a dependency on `fsevents`).
It was possible to automatically do this for all of your dependencies, but it was inconvenient. You had to write some code that read your `package.json` file and passed the keys of the `dependencies`, `devDependencies`, `peerDependencies`, and/or `optionalDependencies` maps to esbuild as external packages (either that or write a plugin to mark all package paths as external). Previously esbuild's recommendation for making this easier was to do `--external:./node_modules/*` (added in version 0.14.13). However, this was a bad idea because it caused compatibility problems with many node packages as it caused esbuild to mark the post-resolve path as external instead of the pre-resolve path. Doing that could break packages that are published as both CommonJS and ESM if esbuild's bundler is also used to do a module format conversion.
With this release, you can now do the following to automatically exclude all packages from your bundle:
- CLI:
esbuild --bundle --packages=external
- JS:
```js
esbuild.build({
bundle: true,
packages: 'external',
})
```
- Go:
```go
api.Build(api.BuildOptions{
Bundle: true,
Packages: api.PackagesExternal,
})
```
Doing `--external:./node_modules/*` is still possible and still has the same behavior, but is no longer recommended. I recommend that you use the new `packages` feature instead.
- Fix some subtle bugs with tagged template literals
This release fixes a bug where minification could incorrectly change the value of `this` within tagged template literal function calls:
```js
// Original code
function f(x) {
let z = y.z
return z``
}
// Old output (with --minify)
function f(n){return y.z``}
// New output (with --minify)
function f(n){return(0,y.z)``}
```
This release also fixes a bug where using optional chaining with `--target=es2019` or earlier could incorrectly change the value of `this` within tagged template literal function calls:
```js
// Original code
var obj = {
foo: function() {
console.log(this === obj);
}
};
(obj?.foo)``;
// Old output (with --target=es6)
var obj = {
foo: function() {
console.log(this === obj);
}
};
(obj == null ? void 0 : obj.foo)``;
// New output (with --target=es6)
var __freeze = Object.freeze;
var __defProp = Object.defineProperty;
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
var _a;
var obj = {
foo: function() {
console.log(this === obj);
}
};
(obj == null ? void 0 : obj.foo).call(obj, _a || (_a = __template([""])));
```
- Some slight minification improvements
The following minification improvements were implemented:
- `if (~a !== 0) throw x;` => `if (~a) throw x;`
- `if ((a | b) !== 0) throw x;` => `if (a | b) throw x;`
- `if ((a & b) !== 0) throw x;` => `if (a & b) throw x;`
- `if ((a ^ b) !== 0) throw x;` => `if (a ^ b) throw x;`
- `if ((a << b) !== 0) throw x;` => `if (a << b) throw x;`
- `if ((a >> b) !== 0) throw x;` => `if (a >> b) throw x;`
- `if ((a >>> b) !== 0) throw x;` => `if (a >>> b) throw x;`
- `if (!!a || !!b) throw x;` => `if (a || b) throw x;`
- `if (!!a && !!b) throw x;` => `if (a && b) throw x;`
- `if (a ? !!b : !!c) throw x;` => `if (a ? b : c) throw x;`
### [`v0.16.4`](https://togithub.com/evanw/esbuild/blob/HEAD/CHANGELOG.md#0164)
[Compare Source](https://togithub.com/evanw/esbuild/compare/v0.16.3...v0.16.4)
- Fix binary downloads from the `@esbuild/` scope for Deno ([#2729](https://togithub.com/evanw/esbuild/issues/2729))
Version 0.16.0 of esbuild moved esbuild's binary executables into npm packages under the `@esbuild/` scope, which accidentally broke the binary downloader script for Deno. This release fixes this script so it should now be possible to use esbuild version 0.16.4+ with Deno.
### [`v0.16.3`](https://togithub.com/evanw/esbuild/blob/HEAD/CHANGELOG.md#0163)
[Compare Source](https://togithub.com/evanw/esbuild/compare/v0.16.2...v0.16.3)
- Fix a hang with the JS API in certain cases ([#2727](https://togithub.com/evanw/esbuild/issues/2727))
A change that was made in version 0.15.13 accidentally introduced a case when using esbuild's JS API could cause the node process to fail to exit. The change broke esbuild's watchdog timer, which detects if the parent process no longer exists and then automatically exits esbuild. This hang happened when you ran node as a child process with the `stderr` stream set to `pipe` instead of `inherit`, in the child process you call esbuild's JS API and pass `incremental: true` but do not call `dispose()` on the returned `rebuild` object, and then call `process.exit()`. In that case the parent node process was still waiting for the esbuild process that was created by the child node process to exit. The change made in version 0.15.13 was trying to avoid using Go's `sync.WaitGroup` API incorrectly because the API is not thread-safe. Instead of doing this, I have now reverted that change and implemented a thread-safe version of the `sync.WaitGroup` API for esbuild to use instead.
Configuration
📅 Schedule: Branch creation - "before 3am on Monday" (UTC), Automerge - 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.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
16.18.6
->16.18.8
0.16.2
->0.16.5
Release Notes
evanw/esbuild
### [`v0.16.5`](https://togithub.com/evanw/esbuild/blob/HEAD/CHANGELOG.md#0165) [Compare Source](https://togithub.com/evanw/esbuild/compare/v0.16.4...v0.16.5) - Make it easy to exclude all packages from a bundle ([#1958](https://togithub.com/evanw/esbuild/issues/1958), [#1975](https://togithub.com/evanw/esbuild/issues/1975), [#2164](https://togithub.com/evanw/esbuild/issues/2164), [#2246](https://togithub.com/evanw/esbuild/issues/2246), [#2542](https://togithub.com/evanw/esbuild/issues/2542)) When bundling for node, it's often necessary to exclude npm packages from the bundle since they weren't designed with esbuild bundling in mind and don't work correctly after being bundled. For example, they may use `__dirname` and run-time file system calls to load files, which doesn't work after bundling with esbuild. Or they may compile a native `.node` extension that has similar expectations about the layout of the file system that are no longer true after bundling (even if the `.node` extension is copied next to the bundle). The way to get this to work with esbuild is to use the `--external:` flag. For example, the [`fsevents`](https://www.npmjs.com/package/fsevents) package contains a native `.node` extension and shouldn't be bundled. To bundle code that uses it, you can pass `--external:fsevents` to esbuild to exclude it from your bundle. You will then need to ensure that the `fsevents` package is still present when you run your bundle (e.g. by publishing your bundle to npm as a package with a dependency on `fsevents`). It was possible to automatically do this for all of your dependencies, but it was inconvenient. You had to write some code that read your `package.json` file and passed the keys of the `dependencies`, `devDependencies`, `peerDependencies`, and/or `optionalDependencies` maps to esbuild as external packages (either that or write a plugin to mark all package paths as external). Previously esbuild's recommendation for making this easier was to do `--external:./node_modules/*` (added in version 0.14.13). However, this was a bad idea because it caused compatibility problems with many node packages as it caused esbuild to mark the post-resolve path as external instead of the pre-resolve path. Doing that could break packages that are published as both CommonJS and ESM if esbuild's bundler is also used to do a module format conversion. With this release, you can now do the following to automatically exclude all packages from your bundle: - CLI: esbuild --bundle --packages=external - JS: ```js esbuild.build({ bundle: true, packages: 'external', }) ``` - Go: ```go api.Build(api.BuildOptions{ Bundle: true, Packages: api.PackagesExternal, }) ``` Doing `--external:./node_modules/*` is still possible and still has the same behavior, but is no longer recommended. I recommend that you use the new `packages` feature instead. - Fix some subtle bugs with tagged template literals This release fixes a bug where minification could incorrectly change the value of `this` within tagged template literal function calls: ```js // Original code function f(x) { let z = y.z return z`` } // Old output (with --minify) function f(n){return y.z``} // New output (with --minify) function f(n){return(0,y.z)``} ``` This release also fixes a bug where using optional chaining with `--target=es2019` or earlier could incorrectly change the value of `this` within tagged template literal function calls: ```js // Original code var obj = { foo: function() { console.log(this === obj); } }; (obj?.foo)``; // Old output (with --target=es6) var obj = { foo: function() { console.log(this === obj); } }; (obj == null ? void 0 : obj.foo)``; // New output (with --target=es6) var __freeze = Object.freeze; var __defProp = Object.defineProperty; var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) })); var _a; var obj = { foo: function() { console.log(this === obj); } }; (obj == null ? void 0 : obj.foo).call(obj, _a || (_a = __template([""]))); ``` - Some slight minification improvements The following minification improvements were implemented: - `if (~a !== 0) throw x;` => `if (~a) throw x;` - `if ((a | b) !== 0) throw x;` => `if (a | b) throw x;` - `if ((a & b) !== 0) throw x;` => `if (a & b) throw x;` - `if ((a ^ b) !== 0) throw x;` => `if (a ^ b) throw x;` - `if ((a << b) !== 0) throw x;` => `if (a << b) throw x;` - `if ((a >> b) !== 0) throw x;` => `if (a >> b) throw x;` - `if ((a >>> b) !== 0) throw x;` => `if (a >>> b) throw x;` - `if (!!a || !!b) throw x;` => `if (a || b) throw x;` - `if (!!a && !!b) throw x;` => `if (a && b) throw x;` - `if (a ? !!b : !!c) throw x;` => `if (a ? b : c) throw x;` ### [`v0.16.4`](https://togithub.com/evanw/esbuild/blob/HEAD/CHANGELOG.md#0164) [Compare Source](https://togithub.com/evanw/esbuild/compare/v0.16.3...v0.16.4) - Fix binary downloads from the `@esbuild/` scope for Deno ([#2729](https://togithub.com/evanw/esbuild/issues/2729)) Version 0.16.0 of esbuild moved esbuild's binary executables into npm packages under the `@esbuild/` scope, which accidentally broke the binary downloader script for Deno. This release fixes this script so it should now be possible to use esbuild version 0.16.4+ with Deno. ### [`v0.16.3`](https://togithub.com/evanw/esbuild/blob/HEAD/CHANGELOG.md#0163) [Compare Source](https://togithub.com/evanw/esbuild/compare/v0.16.2...v0.16.3) - Fix a hang with the JS API in certain cases ([#2727](https://togithub.com/evanw/esbuild/issues/2727)) A change that was made in version 0.15.13 accidentally introduced a case when using esbuild's JS API could cause the node process to fail to exit. The change broke esbuild's watchdog timer, which detects if the parent process no longer exists and then automatically exits esbuild. This hang happened when you ran node as a child process with the `stderr` stream set to `pipe` instead of `inherit`, in the child process you call esbuild's JS API and pass `incremental: true` but do not call `dispose()` on the returned `rebuild` object, and then call `process.exit()`. In that case the parent node process was still waiting for the esbuild process that was created by the child node process to exit. The change made in version 0.15.13 was trying to avoid using Go's `sync.WaitGroup` API incorrectly because the API is not thread-safe. Instead of doing this, I have now reverted that change and implemented a thread-safe version of the `sync.WaitGroup` API for esbuild to use instead.Configuration
📅 Schedule: Branch creation - "before 3am on Monday" (UTC), Automerge - 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.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
This PR has been generated by Mend Renovate. View repository job log here.