Skip to content

Commit

Permalink
fix #2357: add rhino and hermes engine targets
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jun 30, 2022
1 parent 841846f commit 4e631f5
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

Deno doesn't support FreeBSD, but it's possible to build Deno for FreeBSD with some additional patches on top. This release of esbuild changes esbuild's Deno installer to download esbuild's FreeBSD binary in this situation. This configuration is unsupported although in theory everything should work.

* Add some more target JavaScript engines ([#2357](https://github.com/evanw/esbuild/issues/2357))

This release adds the [Rhino](https://github.com/mozilla/rhino) and [Hermes](https://hermesengine.dev/) JavaScript engines to the set of engine identifiers that can be passed to the `--target` flag. You can use this to restrict esbuild to only using JavaScript features that are supported on those engines in the output files that esbuild generates.

## 0.14.47

* Make global names more compact when `||=` is available ([#2331](https://github.com/evanw/esbuild/issues/2331))
Expand Down
39 changes: 39 additions & 0 deletions internal/compat/js_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ const (
Edge
ES
Firefox
Hermes
IE
IOS
Node
Opera
Rhino
Safari
)

Expand All @@ -26,6 +28,8 @@ func (e Engine) String() string {
return "es"
case Firefox:
return "firefox"
case Hermes:
return "hermes"
case IE:
return "ie"
case IOS:
Expand All @@ -34,6 +38,8 @@ func (e Engine) String() string {
return "node"
case Opera:
return "opera"
case Rhino:
return "rhino"
case Safari:
return "safari"
}
Expand Down Expand Up @@ -224,6 +230,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{13, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{36, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{5, 0, 0}}},
Opera: {{start: v{33, 0, 0}}},
Expand All @@ -234,9 +241,11 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{13, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{45, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{6, 0, 0}}},
Opera: {{start: v{36, 0, 0}}},
Rhino: {{start: v{1, 7, 13}}},
Safari: {{start: v{10, 0, 0}}},
},
AsyncAwait: {
Expand Down Expand Up @@ -267,6 +276,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
IOS: {{start: v{14, 0, 0}}},
Node: {{start: v{10, 4, 0}}},
Opera: {{start: v{54, 0, 0}}},
Rhino: {{start: v{1, 7, 14}}},
Safari: {{start: v{14, 0, 0}}},
},
Class: {
Expand Down Expand Up @@ -382,17 +392,20 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{14, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{51, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IE: {{start: v{11, 0, 0}}},
IOS: {{start: v{11, 0, 0}}},
Node: {{start: v{6, 0, 0}}},
Opera: {{start: v{36, 0, 0}}},
Rhino: {{start: v{1, 7, 13}}},
Safari: {{start: v{11, 0, 0}}},
},
DefaultArgument: {
Chrome: {{start: v{49, 0, 0}}},
Edge: {{start: v{14, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{53, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{6, 0, 0}}},
Opera: {{start: v{36, 0, 0}}},
Expand All @@ -403,9 +416,11 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{18, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{53, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{6, 5, 0}}},
Opera: {{start: v{38, 0, 0}}},
Rhino: {{start: v{1, 7, 14}}},
Safari: {{start: v{10, 0, 0}}},
},
DynamicImport: {
Expand All @@ -423,9 +438,11 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{14, 0, 0}}},
ES: {{start: v{2016, 0, 0}}},
Firefox: {{start: v{52, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 3, 0}}},
Node: {{start: v{7, 0, 0}}},
Opera: {{start: v{39, 0, 0}}},
Rhino: {{start: v{1, 7, 14}}},
Safari: {{start: v{10, 1, 0}}},
},
ExportStarAs: {
Expand All @@ -451,19 +468,23 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{15, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{53, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{6, 5, 0}}},
Opera: {{start: v{38, 0, 0}}},
Rhino: {{start: v{1, 7, 13}}},
Safari: {{start: v{10, 0, 0}}},
},
Generator: {
Chrome: {{start: v{50, 0, 0}}},
Edge: {{start: v{13, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{53, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{6, 0, 0}}},
Opera: {{start: v{37, 0, 0}}},
Rhino: {{start: v{1, 7, 13}}},
Safari: {{start: v{10, 0, 0}}},
},
Hashbang: {
Expand Down Expand Up @@ -494,6 +515,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{85, 0, 0}}},
ES: {{start: v{2021, 0, 0}}},
Firefox: {{start: v{79, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{14, 0, 0}}},
Node: {{start: v{15, 0, 0}}},
Opera: {{start: v{71, 0, 0}}},
Expand All @@ -504,6 +526,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{14, 0, 0}}},
ES: {{start: v{2016, 0, 0}}},
Firefox: {{start: v{47, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 3, 0}}},
Node: {{start: v{6, 0, 0}}},
Opera: {{start: v{36, 0, 0}}},
Expand All @@ -514,6 +537,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{14, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{41, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{5, 0, 0}}},
Opera: {{start: v{33, 0, 0}}},
Expand All @@ -530,6 +554,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{80, 0, 0}}},
ES: {{start: v{2020, 0, 0}}},
Firefox: {{start: v{72, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{13, 4, 0}}},
Node: {{start: v{14, 0, 0}}},
Opera: {{start: v{67, 0, 0}}},
Expand All @@ -540,27 +565,32 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{12, 0, 0}}},
ES: {{start: v{5, 0, 0}}},
Firefox: {{start: v{2, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IE: {{start: v{9, 0, 0}}},
IOS: {{start: v{6, 0, 0}}},
Node: {{start: v{0, 4, 0}}},
Opera: {{start: v{10, 10, 0}}},
Rhino: {{start: v{1, 7, 13}}},
Safari: {{start: v{3, 1, 0}}},
},
ObjectExtensions: {
Chrome: {{start: v{44, 0, 0}}},
Edge: {{start: v{12, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{34, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{4, 0, 0}}},
Opera: {{start: v{31, 0, 0}}},
Rhino: {{start: v{1, 7, 14}}},
Safari: {{start: v{10, 0, 0}}},
},
ObjectRestSpread: {
Chrome: {{start: v{60, 0, 0}}},
Edge: {{start: v{79, 0, 0}}},
ES: {{start: v{2018, 0, 0}}},
Firefox: {{start: v{55, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{11, 3, 0}}},
Node: {{start: v{8, 3, 0}}},
Opera: {{start: v{47, 0, 0}}},
Expand All @@ -571,6 +601,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{79, 0, 0}}},
ES: {{start: v{2019, 0, 0}}},
Firefox: {{start: v{58, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{11, 3, 0}}},
Node: {{start: v{10, 0, 0}}},
Opera: {{start: v{53, 0, 0}}},
Expand All @@ -581,6 +612,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{91, 0, 0}}},
ES: {{start: v{2020, 0, 0}}},
Firefox: {{start: v{74, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{13, 4, 0}}},
Node: {{start: v{16, 9, 0}}},
Opera: {{start: v{77, 0, 0}}},
Expand All @@ -591,6 +623,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{79, 0, 0}}},
ES: {{start: v{2018, 0, 0}}},
Firefox: {{start: v{78, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{11, 3, 0}}},
Node: {{start: v{8, 10, 0}}},
Opera: {{start: v{49, 0, 0}}},
Expand All @@ -601,6 +634,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{79, 0, 0}}},
ES: {{start: v{2018, 0, 0}}},
Firefox: {{start: v{78, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
Node: {{start: v{8, 10, 0}}},
Opera: {{start: v{49, 0, 0}}},
},
Expand Down Expand Up @@ -628,6 +662,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{13, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{46, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{12, 0, 0}}},
Node: {{start: v{6, 0, 0}}},
Opera: {{start: v{37, 0, 0}}},
Expand All @@ -648,6 +683,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{12, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{43, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{10, 0, 0}}},
Node: {{start: v{6, 0, 0}}},
Opera: {{start: v{34, 0, 0}}},
Expand All @@ -658,9 +694,11 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{13, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{34, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{9, 0, 0}}},
Node: {{start: v{4, 0, 0}}},
Opera: {{start: v{28, 0, 0}}},
Rhino: {{start: v{1, 7, 14}}},
Safari: {{start: v{9, 0, 0}}},
},
TopLevelAwait: {
Expand All @@ -687,6 +725,7 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Edge: {{start: v{12, 0, 0}}},
ES: {{start: v{2015, 0, 0}}},
Firefox: {{start: v{53, 0, 0}}},
Hermes: {{start: v{0, 7, 0}}},
IOS: {{start: v{9, 0, 0}}},
Node: {{start: v{4, 0, 0}}},
Opera: {{start: v{31, 0, 0}}},
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/api_js_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const (
EngineNode
EngineOpera
EngineSafari
EngineHermes
EngineRhino
)

func convertEngineName(engine EngineName) compat.Engine {
Expand All @@ -35,6 +37,10 @@ func convertEngineName(engine EngineName) compat.Engine {
return compat.Opera
case EngineSafari:
return compat.Safari
case EngineHermes:
return compat.Hermes
case EngineRhino:
return compat.Rhino
default:
panic("Invalid engine name")
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/cli_js_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ var validEngines = map[string]api.EngineName{
"chrome": api.EngineChrome,
"edge": api.EngineEdge,
"firefox": api.EngineFirefox,
"hermes": api.EngineHermes,
"ie": api.EngineIE,
"ios": api.EngineIOS,
"node": api.EngineNode,
"opera": api.EngineOpera,
"rhino": api.EngineRhino,
"safari": api.EngineSafari,
}
4 changes: 4 additions & 0 deletions scripts/compat-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ const engines = [
'node',
'opera',
'safari',

// Uncommon JavaScript runtimes
'hermes',
'rhino',
]

function mergeVersions(target, res) {
Expand Down

0 comments on commit 4e631f5

Please sign in to comment.