Skip to content

Commit

Permalink
fix #951: lower object rest and spread for v8
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Mar 11, 2021
1 parent 4725dae commit b1a394b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,10 @@

Previously conditional CSS imports such as `@import "print.css" print;` was not supported at all and was considered a syntax error. With this release, it is now supported in all cases except when bundling an internal import. Support for bundling internal CSS imports is planned but will happen in a later release.

* Always lower object spread and rest when targeting V8 ([#951](https://github.com/evanw/esbuild/issues/951))

This release causes object spread (e.g. `a = {...b}`) and object rest (e.g. `{...a} = b`) to always be lowered to a manual implementation instead of using native syntax when the `--target=` parameter includes a V8-based JavaScript runtime such as `chrome`, `edge`, or `node`. It turns out this feature is implemented inefficiently in V8 and copying properties over to a new object is around a 2x performance improvement. In addition, doing this manually instead of using the native implementation generates a lot less work for the garbage collector. You can see [V8 bug 11536](https://bugs.chromium.org/p/v8/issues/detail?id=11536) for details. If the V8 performance bug is eventually fixed, the translation of this syntax will be disabled again for V8-based targets containing the bug fix.

## 0.9.0

**This release contains backwards-incompatible changes.** Since esbuild is before version 1.0.0, these changes have been released as a new minor version to reflect this (as [recommended by npm](https://docs.npmjs.com/cli/v6/using-npm/semver/)). You should either be pinning the exact version of `esbuild` in your `package.json` file or be using a version range syntax that only accepts patch upgrades such as `^0.8.0`. See the documentation about [semver](https://docs.npmjs.com/cli/v6/using-npm/semver/) for more information.
Expand Down
3 changes: 0 additions & 3 deletions internal/compat/js_table.go
Expand Up @@ -313,12 +313,9 @@ var jsTable = map[JSFeature]map[Engine][]int{
Safari: {7, 1},
},
ObjectRestSpread: {
Chrome: {60},
Edge: {79},
ES: {2018},
Firefox: {55},
IOS: {11, 3},
Node: {8, 3},
Safari: {11, 1},
},
OptionalCatchBinding: {
Expand Down
7 changes: 7 additions & 0 deletions scripts/compat-table.js
Expand Up @@ -177,6 +177,13 @@ for (const test of [...es5.tests, ...es6.tests, ...stage4.tests, ...stage1to3.te
}
}

// Work around V8-specific issues
for (const v8 of ['chrome', 'edge', 'node']) {
// Always lower object rest and spread for V8-based JavaScript VMs because of
// a severe performance issue: https://bugs.chromium.org/p/v8/issues/detail?id=11536
delete versions.ObjectRestSpread[v8]
}

for (const feature in features) {
if (!features[feature].found) {
throw new Error(`Did not find ${feature}`)
Expand Down

0 comments on commit b1a394b

Please sign in to comment.