Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct CLI option to enable TDZ in Hermes #138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
// Hermes version 0.10.0 introduced `-Xenable-tdz` to replace `-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 [_, version] = /Hermes release version: (.*)/.exec(stdout);
if (/^0[.][0-9][.]/.test(version)) {
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