国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

[BABEL] Note: The code generator has deoptimised the styling of......as it exceeds the max of 500KB

這篇具有很好參考價(jià)值的文章主要介紹了[BABEL] Note: The code generator has deoptimised the styling of......as it exceeds the max of 500KB。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

前言

在打包項(xiàng)目的時(shí)候遇到了這種類型的錯(cuò)誤,為了更好的解決這種問(wèn)題,了解一下babel相關(guān)的知識(shí),以及如何解決這類問(wèn)題的方法。

解決辦法

在項(xiàng)目的根目錄下創(chuàng)建.banelrc文件,內(nèi)容為

{
   "compact": false,
   "presets": ["env", "stage-0"],
   "plugins": ["transform-runtime"]
}

針對(duì)問(wèn)題的擴(kuò)展

1.什么是babel

它是一個(gè)可以將javascript語(yǔ)言的語(yǔ)法從最新的語(yǔ)法轉(zhuǎn)換成向后兼容的語(yǔ)法,使項(xiàng)目可以在當(dāng)前和舊版本的瀏覽器或其他環(huán)境中運(yùn)行。

2.babel配置

在babel執(zhí)行編譯的過(guò)程中,會(huì)從項(xiàng)目的根目錄下的.babelrc文件中讀取配置,該文件主要是對(duì)預(yù)設(shè)(presets) 和 插件(plugins) 進(jìn)行配置。

2.1 plugins

該屬性是告訴babel要使用那些插件,這些插件可以控制如何轉(zhuǎn)換代碼。

Babel默認(rèn)只轉(zhuǎn)換新的javascript語(yǔ)法,而不轉(zhuǎn)換新的API,比如 Set, Maps, Proxy, Promise 等全局對(duì)象。以及一些在全局對(duì)象上的方法(比如 Object.assign)都不會(huì)轉(zhuǎn)碼。這時(shí)就需要選擇合適的插件進(jìn)行轉(zhuǎn)碼。

babel提供了三種轉(zhuǎn)換的插件:

1.babel-polyfill
當(dāng)運(yùn)行環(huán)境中并沒(méi)有實(shí)現(xiàn)的一些方法,它都會(huì)通過(guò)向全局對(duì)象和內(nèi)置對(duì)象的prototype上添加方法來(lái)實(shí)現(xiàn)的。這樣會(huì)造成全局空間污染。

2.babel-runtime
它不會(huì)污染全局對(duì)象和內(nèi)置對(duì)象的原型,比如說(shuō)我們需要Promise,我們只需要import Promise from 'babel-runtime/core-js/promise’即可,但它需要每個(gè)文件都要家import,會(huì)造成代碼冗余

3.babel-plugin-transform-runtime
它是針對(duì)babel-runtime進(jìn)行了公共方法的抽離,減少代碼冗余。

因此我們通常會(huì)選擇第三種插件進(jìn)行配置

{
  'plugins': [
    [
      'transform-runtime', 
      {
        'helpers': ture,	
        // 默認(rèn)為true,是否開(kāi)啟內(nèi)聯(lián)的babel helpers(即babel或者環(huán)境本來(lái)存在的某些對(duì)象方法函數(shù))如:extends,etc這樣的
在調(diào)用模塊名字時(shí)將被替換名字。
        'polyfill': true,
        // 默認(rèn)為true,是否把內(nèi)置的東西(Promise, Set, Map)等轉(zhuǎn)換成非全局污染的。
        'regenerator': true,
        // 默認(rèn)為true,是否開(kāi)啟generator函數(shù)轉(zhuǎn)換成使用regenerator runtime來(lái)避免污染全局域。
        'moduleName': 'babel-runtime'
        // 默認(rèn)為 babel-runtime,當(dāng)調(diào)用輔助 設(shè)置模塊(module)名字/路徑.
      }
    ]
  ]
}

2.2 presets

presets屬性告訴Babel要轉(zhuǎn)換的源碼使用了哪些新的語(yǔ)法特性,presets是一組Plugins的集合。

babel-preset-env 會(huì)根據(jù)目標(biāo)環(huán)境選擇不支持的新特性來(lái)轉(zhuǎn)譯。

{
  'presets': [
    ['env', {
      'target': {
        'browsers': ['last 2 versions', 'safari >= 7'],
        // 支持每個(gè)瀏覽器最后兩個(gè)版本和safari大于等于7版本所需的polyfill代碼轉(zhuǎn)換
        'browsers': '> 5%',
        // 支持市場(chǎng)份額超過(guò)5%的瀏覽器
        'chrome': 56,
        // 支持指定瀏覽器版本
        "node": "current"
        // 如果通過(guò)Babel編譯Node.js代碼的話,可以設(shè)置支持當(dāng)前運(yùn)行版本的nodejs。
      },
      'modules': false
      // 啟用將ES6模塊語(yǔ)法轉(zhuǎn)換為另一種模塊類型。將該設(shè)置為false就不會(huì)轉(zhuǎn)換模塊。默認(rèn)為 'commonjs'.但是現(xiàn)在webpack都幫我做了這件事了,所以我們不需要babel來(lái)做,因此需要在babel配置項(xiàng)中設(shè)置modules為false.
      "include": ["transform-es2015-arrow-functions", "es6.map"]
      // 包含一些插件
      "exclude": ["transform-regenerator", "es6.set"]
      // 排除一些插件
    }]
  ]
}

2.3 compact

參數(shù)類型:Boolean | “auto” 默認(rèn)值:“auto” 該配置選項(xiàng)引導(dǎo) babel 是否開(kāi)啟緊湊模式,緊湊模式會(huì)省略所有可選的換行符和空格. 當(dāng)配置選項(xiàng)是”auto“的時(shí)候,babel 會(huì)根據(jù)文件的字符數(shù)判斷,當(dāng)字符長(zhǎng)度 code.length > 50,000 時(shí) 會(huì)開(kāi)啟緊湊模式文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-782907.html

到了這里,關(guān)于[BABEL] Note: The code generator has deoptimised the styling of......as it exceeds the max of 500KB的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 成功解決Pycharm報(bào)錯(cuò):Note: you may need to restart the kernel to use updated packages.

    成功解決Pycharm報(bào)錯(cuò):Note: you may need to restart the kernel to use updated packages.

    pycharm中 import sklearn 報(bào)錯(cuò): 然后在pycharm的控制臺(tái)console中使用 pip install sklearn 安裝了sklearn包,使用 pip list 命令查看安裝成功: 但是,最 玄學(xué) 的事情來(lái)了,明明安裝成功,import卻還是和剛開(kāi)始一樣的報(bào)錯(cuò)。 細(xì)看發(fā)現(xiàn) pip list 的末尾有一句: 我知道jupyter怎么重啟內(nèi)核,但是p

    2024年02月04日
    瀏覽(63)
  • python報(bào)錯(cuò):Note: you may need to restart the kernel to use updated packages終極解決辦法

    python報(bào)錯(cuò):Note: you may need to restart the kernel to use updated packages終極解決辦法

    python執(zhí)行:pip install 庫(kù)名 報(bào)錯(cuò):Note: you may need to restart the kernel to use updated packages. 翻譯過(guò)來(lái)為: 注意:你可能需要重新啟動(dòng)內(nèi)核才能使用更新的軟件包 。 于是到網(wǎng)上找各種解決方法,重新按照python、設(shè)置環(huán)境變量,cmd中找路徑什么的,能試的方法都試了,最終費(fèi)了九牛二虎

    2024年02月11日
    瀏覽(24)
  • The injection point has the following annotations: - @org.springframework.beans.factory.annotation.

    Spingboot項(xiàng)目啟動(dòng)時(shí)報(bào)一下錯(cuò)誤,錯(cuò)誤如下: 報(bào)錯(cuò)大概意思就是,無(wú)法找到對(duì)應(yīng)的dao接口,經(jīng)過(guò)分析發(fā)現(xiàn),未設(shè)置保掃描 解決方案如下:在啟動(dòng)類上加入以下代碼即可

    2024年02月03日
    瀏覽(39)
  • Multimodel Image synthesis and editing:The generative AI Era

    Multimodel Image synthesis and editing:The generative AI Era

    1.introduction 基于GAN和擴(kuò)散模型,通過(guò)融入多模態(tài)引導(dǎo)來(lái)調(diào)節(jié)生成過(guò)程,從不同的多模態(tài)信號(hào)中合成圖像;是為多模態(tài)圖像合成和編輯使用預(yù)訓(xùn)練模型,通過(guò)在GAN潛在空間中進(jìn)行反演,應(yīng)用引導(dǎo)函數(shù),或調(diào)整擴(kuò)散模型的潛在空間和嵌入。 2.modality foundations 每一種信息源或形式都

    2024年02月09日
    瀏覽(21)
  • 解決The injection point has the following annotations:@org.springframework.beans.factory.annotation錯(cuò)誤~

    解決The injection point has the following annotations:@org.springframework.beans.factory.annotation錯(cuò)誤~

    錯(cuò)誤描述如下所示: 錯(cuò)誤原因:未將 com.reggie.service.EmployeeService 類型的bean進(jìn)行自動(dòng)裝配 我的錯(cuò)誤原因是忘記給EmployeeService的實(shí)現(xiàn)類添加注解@Service,也就是未實(shí)現(xiàn)自動(dòng)裝配,那么只需要添加注解即可解決該問(wèn)題

    2024年01月20日
    瀏覽(20)
  • 已解決The last packet sent successfully to the server was 0 milliseconds ago. The driver has not receiv

    已解決The last packet sent successfully to the server was 0 milliseconds ago. The driver has not receiv

    注:此文章是在mysql8版本的前提下編寫(xiě)的。 在我們使用springcloud在連接mysql數(shù)據(jù)庫(kù)時(shí),有時(shí)會(huì)碰到如下這種異常: 為此我上網(wǎng)查了不少資料,在這里小總結(jié)一下: 1. 連接url是否正確(自己看看useSSL是否為false): 2.數(shù)據(jù)庫(kù)服務(wù)是否打開(kāi): 找到MySql服務(wù): 3.網(wǎng)上最多解決的等待

    2024年01月16日
    瀏覽(20)
  • 【git報(bào)錯(cuò)】The current branch dev has no upstream branch. To push the current branch and set the remote

    【git報(bào)錯(cuò)】The current branch dev has no upstream branch. To push the current branch and set the remote

    發(fā)現(xiàn)問(wèn)題 本地新建了一個(gè)dev分支,然后把dev分支下的代碼push到遠(yuǎn)程倉(cāng)庫(kù)中,使用git push,但是報(bào)錯(cuò)了,如下: fatal: The current branch dev has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin dev 翻譯 錯(cuò)誤:當(dāng)前分支:dev沒(méi)有遠(yuǎn)程對(duì)應(yīng)的dev分支

    2024年02月11日
    瀏覽(25)
  • java.lang.IllegalArgumentException: This Style does not belong to the supplied Workbook異常的解決辦法

    java.lang.IllegalArgumentException: This Style does not belong to the supplied Workbook異常的解決辦法 java.lang.IllegalArgumentException: This Style does not belong to the supplied Workbook異常 在Java中,當(dāng)你嘗試在一個(gè)Workbook(例如Apache POI庫(kù)中的HSSFWorkbook或XSSFWorkbook)上應(yīng)用一個(gè)Style對(duì)象,但該Style不是由同一個(gè)

    2024年04月28日
    瀏覽(310)
  • An unexpected error has occurred. Conda has prepared the above report

    An unexpected error has occurred. Conda has prepared the above report

    今日在服務(wù)器上創(chuàng)建anaconda虛擬環(huán)境的時(shí)候,出現(xiàn)了如下報(bào)錯(cuò) ?直接上解決方案 在終端中輸入如下指令 ?如果出現(xiàn)以下提示,說(shuō)明多了一個(gè)文件 ?輸入以下指令刪掉這個(gè)文件 ?隨后可以正常完成虛擬環(huán)境的創(chuàng)建

    2024年02月13日
    瀏覽(24)
  • RuntimeError: The server socket has failed to listen on any local network address. The server socket

    Error details: RuntimeError: The server socket has failed to listen on any local network address. The server socket has failed to bind to [::]:29500 (errno: 98 - Address already in use). The server socket has failed to bind to ?UNKNOWN? (errno: 98 - Address already in use). This error occurs when using torch.nn.parallel.DistributedDataParallel to train a mod

    2024年02月10日
    瀏覽(17)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包