Skip to content

Commit

Permalink
fix #1594: update manual compat table overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Sep 12, 2021
1 parent 6a3d3a6 commit 17e6cb2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## Unreleased

* Update JavaScript syntax feature compatibility tables ([#1594](https://github.com/evanw/esbuild/issues/1594))

Most JavaScript syntax feature compatibility data is able to be obtained automatically via https://kangax.github.io/compat-table/. However, they are missing data for quite a few new JavaScript features (see ([kangax/compat-table#1034](https://github.com/kangax/compat-table/issues/1034))) so data on these new features has to be added manually. This release manually adds a few new entries:

* Top-level await

This feature lets you use `await` at the top level of a module, outside of an `async` function. Doing this holds up the entire module instantiation operation until the awaited expression is resolved or rejected. This release marks this feature as supported in Edge 89, Firefox 89, and Safari 15 (it was already marked as supported in Chrome 89 and Node 14.8). The data source for this is https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await.

* Arbitrary module namespace identifier names

This lets you use arbitrary strings as module namespace identifier names as long as they are valid UTF-16 strings. An example is `export { x as "🍕" }` which can then be imported as `import { "🍕" as y } from "./example.js"`. This release marks this feature as supported in Firefox 87 (it was already marked as supported in Chrome 90 and Node 16). The data source for this is https://bugzilla.mozilla.org/show_bug.cgi?id=1670044.

I would also like to add data for Safari. They have recently added support for arbitrary module namespace identifier names (https://bugs.webkit.org/show_bug.cgi?id=217576) and `export * as` (https://bugs.webkit.org/show_bug.cgi?id=214379). However, I have no idea how to determine which Safari release these bugs correspond to so this compatibility data for Safari has been omitted.

## 0.12.26

* Add `--analyze` to print information about the bundle ([#1568](https://github.com/evanw/esbuild/issues/1568))
Expand Down
12 changes: 8 additions & 4 deletions internal/compat/js_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ func (features JSFeature) Has(feature JSFeature) bool {

var jsTable = map[JSFeature]map[Engine][]int{
ArbitraryModuleNamespaceNames: {
Chrome: {90},
Node: {16},
Chrome: {90},
Firefox: {87},
Node: {16},
},
ArraySpread: {
Chrome: {46},
Expand Down Expand Up @@ -419,8 +420,11 @@ var jsTable = map[JSFeature]map[Engine][]int{
Safari: {9},
},
TopLevelAwait: {
Chrome: {89},
Node: {14, 8},
Chrome: {89},
Edge: {89},
Firefox: {89},
Node: {14, 8},
Safari: {15},
},
UnicodeEscapes: {
Chrome: {44},
Expand Down
18 changes: 16 additions & 2 deletions scripts/compat-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ mergeVersions('ExportStarAs', {
es2020: true,
firefox80: true,
node12: true, // From https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export

// This feature has been implemented in Safari but I have no idea what version
// this bug corresponds to: https://bugs.webkit.org/show_bug.cgi?id=214379
})

// Manually copied from https://caniuse.com/#search=import.meta
Expand All @@ -180,7 +183,10 @@ mergeVersions('ImportMeta', {
// Manually copied from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await
mergeVersions('TopLevelAwait', {
chrome89: true,
edge89: true,
firefox89: true,
node14_8: true,
safari15: true,
})

// Manually copied from https://caniuse.com/es6-module-dynamic-import
Expand All @@ -193,15 +199,23 @@ mergeVersions('DynamicImport', {
safari11_1: true,
})

// From https://github.com/tc39/ecma262/pull/2154#issuecomment-825201030
mergeVersions('ArbitraryModuleNamespaceNames', {
// From https://github.com/tc39/ecma262/pull/2154#issuecomment-825201030
chrome90: true,
node16: true,

// From https://bugzilla.mozilla.org/show_bug.cgi?id=1670044
firefox87: true,

// This feature has been implemented in Safari but I have no idea what version
// this bug corresponds to: https://bugs.webkit.org/show_bug.cgi?id=217576
})

// From https://www.chromestatus.com/feature/5765269513306112
mergeVersions('ImportAssertions', {
// From https://www.chromestatus.com/feature/5765269513306112
chrome91: true,

// Not yet in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1668330
})

for (const test of [...es5.tests, ...es6.tests, ...stage4.tests, ...stage1to3.tests]) {
Expand Down

0 comments on commit 17e6cb2

Please sign in to comment.