Skip to content

Commit ebfa38a

Browse files
committed
feat: static hermes support (undocumented)
hermes-shermes
1 parent 5524908 commit ebfa38a

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

bin/find-binary.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function findBinaryOnce(name) {
6060
case 'ladybird-js': // naming by esvu
6161
case 'engine262':
6262
return findFile([jsvu, esvu])
63+
case 'shermes': // our temporary name for static hermes
6364
case 'xs':
6465
return findFile([jsvu, esvu], false)
6566
case 'electron':

bin/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const DEFAULT_PATTERNS = [`**/?(*.)+(spec|test).?([cm])[jt]s?(x)`] // do not tru
2020
const bundleOpts = { pure: true, bundle: true, esbuild: true, ts: 'auto' }
2121
const bareboneOpts = { ...bundleOpts, barebone: true }
2222
const hermesA = ['-w', '-Xmicrotask-queue'] // -Xes6-class fails with -O0 / -Og, --block-scoping fails in default, any of that is bad
23+
const hermesS = [...hermesA, '-Xes6-block-scoping']
2324
const denoA = ['run', '--allow-all'] // also will set DENO_COMPAT=1 env flag below
2425
const denoT = ['test', '--allow-all']
2526
const nodeTS = process.features.typescript ? 'auto' : 'flag'
@@ -42,6 +43,7 @@ const ENGINES = new Map(
4243
'v8:bundle': { binary: 'd8', binaryArgs: ['--expose-gc'], ...bareboneOpts },
4344
'jsc:bundle': { binary: 'jsc', target: 'safari13', ...bareboneOpts },
4445
'hermes:bundle': { binary: 'hermes', binaryArgs: hermesA, target: 'es2018', ...bareboneOpts },
46+
'shermes:bundle': { binary: 'shermes', binaryArgs: hermesS, target: 'es2018', ...bareboneOpts },
4547
'spidermonkey:bundle': { binary: 'spidermonkey', ...bareboneOpts },
4648
'engine262:bundle': { binary: 'engine262', ...bareboneOpts },
4749
'quickjs:bundle': { binary: 'quickjs', binaryArgs: ['--std'], ...bareboneOpts },
@@ -62,7 +64,7 @@ const ENGINES = new Map(
6264
'msedge:playwright': { binary: 'msedge', browsers: 'playwright', ...bundleOpts },
6365
})
6466
)
65-
const barebonesOk = ['v8', 'd8', 'spidermonkey', 'quickjs', 'xs', 'hermes']
67+
const barebonesOk = ['v8', 'd8', 'spidermonkey', 'quickjs', 'xs', 'hermes', 'shermes']
6668
const barebonesUnhandled = ['jsc', 'escargot', 'boa', 'graaljs', 'jerry', 'engine262']
6769

6870
const getEnvFlag = (name) => {
@@ -282,7 +284,7 @@ Object.assign(options, engineOptions)
282284
options.platform = options.binary // binary can be overriden by c8 or electron
283285
const isBrowserLike = options.browsers || options.electron
284286
setEnv('EXODUS_TEST_ENGINE', options.engine) // e.g. 'hermes:bundle', 'node:bundle', 'node:test', 'node:pure'
285-
setEnv('EXODUS_TEST_PLATFORM', options.binary) // e.g. 'hermes', 'node'
287+
setEnv('EXODUS_TEST_PLATFORM', options.binary === 'shermes' ? 'hermes' : options.binary) // e.g. 'hermes', 'node'
286288
setEnv('EXODUS_TEST_TIMEOUT', options.testTimeout)
287289
setEnv('EXODUS_TEST_DEVTOOLS', options.devtools ? '1' : '')
288290
setEnv('EXODUS_TEST_IS_BROWSER', isBrowserLike ? '1' : '')

bundler/bundle.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ export const build = async (...files) => {
498498
],
499499
}
500500

501+
// eslint-disable-next-line unicorn/prefer-switch
501502
if (options.platform === 'hermes') {
502503
Object.assign(config.supported, {
503504
arrow: false,
@@ -506,6 +507,8 @@ export const build = async (...files) => {
506507
'const-and-let': false, // have to explicitly set for esbuild to not emit that in helpers, also to get a safeguard check
507508
'for-await': false,
508509
})
510+
} else if (options.platform === 'shermes') {
511+
Object.assign(config.supported, { 'async-generator': false, 'for-await': false })
509512
} else if (options.platform === 'jerryscript') {
510513
config.supported['class-private-field'] = false
511514
// config.minify = true // breaks on SyntaxError, FIXME

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"test:v8": "EXODUS_TEST_ENGINE=v8:bundle npm run test:_bundle --",
123123
"test:jsc": "EXODUS_TEST_ENGINE=jsc:bundle npm run test:_bundle --",
124124
"test:hermes": "EXODUS_TEST_ENGINE=hermes:bundle npm run test:_bundle --",
125+
"test:shermes": "EXODUS_TEST_ENGINE=shermes:bundle npm run test:_bundle --",
125126
"test:spidermonkey": "EXODUS_TEST_ENGINE=spidermonkey:bundle npm run test:_bundle --",
126127
"test:engine262": "EXODUS_TEST_ENGINE=engine262:bundle npm run test:_bundle --",
127128
"test:quickjs": "EXODUS_TEST_ENGINE=quickjs:bundle npm run test:_bundle --",

0 commit comments

Comments
 (0)