久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

為什么在 Electron 項(xiàng)目中需要 Babel

Why is Babel needed in an Electron project(為什么在 Electron 項(xiàng)目中需要 Babel)
本文介紹了為什么在 Electron 項(xiàng)目中需要 Babel的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我對所有 Javascript 生態(tài)系統(tǒng)都感到很困惑.我正在嘗試 Electron,這似乎是一種很有前途的創(chuàng)建跨平臺應(yīng)用程序的方法,它利用了節(jié)點(diǎn)和 Chrome 的強(qiáng)大功能.我創(chuàng)建了一個小應(yīng)用程序并使用了一些現(xiàn)代"(這讓 C# 程序員發(fā)笑)javascript 概念作為 lambda,并且它開箱即用(我認(rèn)為這很自然,因?yàn)槲矣凶钚掳姹镜墓?jié)點(diǎn)).然后我嘗試下一步,我在使用 Babel 的示例中看到了很多樣板.

I'm quite confused about all the Javascript ecosystem. I'm trying Electron that seems a promising way in creating cross platform apps, leveraging the power of node and Chrome. I create a small app and used some "modern" ( this make a C# programmer laughing ) javascript concepts as lambdas, and it worked out of the box ( I supposed it was natural, since I've the latest version of node ). Then I'm trying to move next, and I see a lot of boilerplating in the examples using for example Babel.

我為什么需要這個?

如果 electron 在一個最新的、預(yù)先知道的、具有最新節(jié)點(diǎn)和 chrome 的環(huán)境中工作,并且如果我將它捆綁在一個應(yīng)用程序中,為什么我不應(yīng)該直接在 ESwhatever 中直接編碼?

If electron works in a up-to date, known in advance, environment with node and chrome up to date, and if I bundle this in a single app, why shouldn't I simply code directly in ESwhatever?

推薦答案

如果你只想要在 electron 中達(dá)到 ES7 的功能,你就不需要 Babel.您有兩個進(jìn)程正在進(jìn)行主進(jìn)程和渲染進(jìn)程.

You don't need Babel if you only want features up to ES7 in electron. You have two processes going on the main process and the render process.

主進(jìn)程:

  • 使用節(jié)點(diǎn)(electron v1.7.x 上的當(dāng)前節(jié)點(diǎn)版本 v7.9.0)
  • 以 99% 的覆蓋率支持 ES6/ES7,但以下情況除外:
    • RegExp.prototype.compile 不返回這個
    • Symbol.toStringTag 不會影響現(xiàn)有的內(nèi)置函數(shù)
    • Array.prototype.values(反正沒人支持)

    渲染過程:

    • 使用 Chromium(當(dāng)前 Chromium 版本為 58)
    • 支持 ES6 99% 和 ES7 覆蓋率約為 85%,您可以通過 new BrowserWindow({ webPreferences: { experimentalFeatures: true } }) 啟用 experimatal features 標(biāo)志來增加支持.李>
    • Uses chromium (Current chromium version is 58)
    • Supports ES6 99% and ES7 with ~85% coverage, you can increase the support by enabling the experimatal features flag via new BrowserWindow({ webPreferences: { experimentalFeatures: true } }).

    請注意,我鼓勵您使用與 electron 用于開發(fā)的相同版本的節(jié)點(diǎn),這將防止不兼容問題.您可以通過查看電子存儲庫中的 .node-version 文件來檢查這一點(diǎn).在當(dāng)前版本中,這將是 v7.9.0.

    Be aware that I would encourage you to use the same version of node that electron uses for development, it will prevent incompatibility issues. you can check this by viewing the .node-version file in the electron repository. At the current version this would be v7.9.0.

    如果你想使用更新的函數(shù),使用 BableJs 仍然是有效的一些操作符,比如擴(kuò)展操作符 ... 幾乎我所有的項(xiàng)目仍然使用帶有Stage 0"預(yù)設(shè)的 babel出于這個原因.

    There are still valid points to use BableJs if you want to use even newer functions some operators like the spread operator ... nearly all of my projects still use babel with the 'Stage 0' preset for that reason.

    檢查支持的 ES 規(guī)范和方法的一些很好的列表

    Some good lists for checking the supported ES spec and methods

    • Chrome 支持表
    • 節(jié)點(diǎn)支持表

    這篇關(guān)于為什么在 Electron 項(xiàng)目中需要 Babel的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

    【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進(jìn)程中創(chuàng)建子窗口時如何修復(fù) BrowserWindow 不是構(gòu)造函數(shù)錯誤) - IT屋-程序員軟件開發(fā)技術(shù)
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應(yīng)用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應(yīng)用程序中訪問相機(jī)/網(wǎng)絡(luò)攝像頭?)
主站蜘蛛池模板: 精品国产乱码久久久久久丨区2区 | 91色视频在线观看 | 伊伊综合网| 久久九| 国产专区在线 | 91伊人| 亚洲一区二区三区四区五区午夜 | 亚洲精品国产精品国自产在线 | 亚洲午夜三级 | 亚洲精品欧美精品 | 久久69精品久久久久久国产越南 | 亚洲一区三区在线观看 | 国产综合网址 | 国产精品一区二区三区久久久 | 亚洲日产精品 | 欧美成人h版在线观看 | 特级生活片 | 亚洲性人人天天夜夜摸 | 午夜精品久久久久久久久久久久久 | h在线播放| 在线视频第一页 | 欧美日韩中文字幕在线 | 狠狠色综合网站久久久久久久 | 亚洲精品日韩在线 | 国色天香综合网 | 三级av网址 | 国产欧美在线 | 久久99精品久久 | 91就要激情| 精品国产视频 | 黄视频在线网站 | 亚洲精品国产精品国自产在线 | 九九视频在线观看视频6 | 成人国内精品久久久久一区 | 国产日韩欧美 | 中文字幕亚洲国产 | 日韩精品久久一区 | 日本一道本视频 | 久久99精品久久久久久国产越南 | 中文字幕一区二区三区不卡 | 国产欧美在线一区二区 |