2015-09-07 72 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 }], 
     
        ], 
     
    }