LoginSignup
0
2

More than 5 years have passed since last update.

Electronでdo式(do-expressions)を使う

Posted at

Electronの起動時にChromiumと同等のフラグをコマンドラインで指定してやると良いみたいです:

$ .\node_modules\.bin\electron --js-flags="--harmony-do-expressions" .
const a = do {
    const i=123
    i*2
}
console.log(a) // => 246



もしくはElectronのmainのスクリプト中でスイッチを指定してやれば、起動コマンドラインでのフラグ指定が不要になるようです。ただしこの場合はブラウザウィンドウ内ではdo式が使えるものの、mainスクリプト等のメインプロセス中では使用不可となってることに注意する必要がありますね。

main.js
const electron = require("electron")
const app = electron.app
app.commandLine.appendSwitch('js-flags', '--harmony-do-expressions')
$ .\node_modules\.bin\electron .

Electronアプリをパッケージ化した際のコマンドラインフラグ指定ってどうなってるんですかね?

参考

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2