2015-09-07 71 views
0

babel-node似乎包括所有變壓器(未驗證),包括應該是可選的變壓器。爲什麼babel-node CLI似乎包含所有變形金剛?

我不想那樣。我只想要默認功能。我現在正在做的是blacklist ing我不想要的可選轉換。

這是怎麼回事?我在這裏錯過了什麼嗎?網站上的文檔是錯誤還是過時?

+0

你有例子嗎?它不應該與正常編譯命令有任何不同。 – loganfsmyth

回答

0

這個答案將假設使用Babel 6,其中es2015是最常用的預設,其中包括babel-plugin-transform-es2015-modules-commonjs。

我給你三種方法來解決這個問題:

  1. 這一個是剛剛安裝通天預設-ES2015本地模塊和配置.babelrc這樣最簡單的:

{ 
 
    "presets": ["es2015-native-modules"], 
 
}

  • 可以安裝巴別預置-ES2015和配置.babelrc這樣禁用堵漏:
  • { 
     
        "presets": ["es2015"], 
     
        "disablePlugins": ["babel-plugin-transform-es2015-modules-commonjs"] 
     
    }

  • 手動安裝所有變換減去模塊-CommonJS的再配置.babelrc像這樣的:
  • { 
     
        plugins: [ 
     
          'transform-es2015-template-literals', 
     
          'transform-es2015-literals', 
     
          'transform-es2015-function-name', 
     
          'transform-es2015-arrow-functions', 
     
          'transform-es2015-block-scoped-functions', 
     
          'transform-es2015-classes', 
     
          'transform-es2015-object-super', 
     
          'transform-es2015-shorthand-properties', 
     
          'transform-es2015-computed-properties', 
     
          'transform-es2015-for-of', 
     
          'transform-es2015-sticky-regex', 
     
          'transform-es2015-unicode-regex', 
     
          'check-es2015-constants', 
     
          'transform-es2015-spread', 
     
          'transform-es2015-parameters', 
     
          'transform-es2015-destructuring', 
     
          'transform-es2015-block-scoping', 
     
          'transform-es2015-typeof-symbol', 
     
          ['transform-regenerator', { async: false, asyncGenerators: false }], 
     
        ], 
     
    }