Skip to content

Commit

Permalink
Use the correct CLI option to enable TDZ in Hermes
Browse files Browse the repository at this point in the history
Fixes tc39#125
  • Loading branch information
gibson042 authored Oct 3, 2023
1 parent 3989a6b commit ea85e19
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/agents/hermes.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,23 @@ class HermesAgent extends ConsoleAgent {
this.args.unshift('-non-strict');
}

this.args.unshift('-Xintl', '-enable-eval', '-fenable-tdz');
// https://github.com/facebook/hermes/commit/f811a0e75f19ab0da7dcf969a61db894fbb3cc35
let tdzArg = '-Xenable-tdz';
try {
const cp = await this.createChildProcess(['-version']);
let stdout = '';
cp.stdout.on('data', str => { stdout += str; });
await new Promise(resolve => { cp.on('close', resolve); });
// https://github.com/facebook/hermes/blob/66d3f87a8fd0436634be8a1049a1db9d3aa6e9c0/lib/CompilerDriver/CompilerDriver.cpp#L2164
const [_, versionStr] = /Hermes release version: (.*)/.exec(stdout);
const [major, minor] = versionStr.split('.');
if (major === '0' && Number(minor) < 10) {
tdzArg = '-fenable-tdz';
}
} catch (error) {
// suppressed
}
this.args.unshift('-Xintl', '-enable-eval', tdzArg);

// There is currently no flag for supporting modules in Hermes
// if (options.module && this.args[0] !== '-m') {
Expand Down

0 comments on commit ea85e19

Please sign in to comment.