本文介绍了Babel 6转换运行时:$ export不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试合并Babel的transform-runtime以使我的代码与IE9兼容。但自从集成它以后,代码甚至不能在Chrome上运行。我收到错误未捕获的TypeError:$ export不是上的函数 es6.object.define-property.js:3 。没有我的.babelrc中的transform-runtime行,一切运行正常。有什么想法吗?

I'm trying to incorporate Babel's transform-runtime to make my code compatible with IE9. But since integrating it, the code won't even run on Chrome. I get the error Uncaught TypeError: $export is not a function on es6.object.define-property.js:3. Without the "transform-runtime" line in my .babelrc, everything runs fine. Any ideas?

这是我的 .babelrc

{
  "plugins": [
    "transform-runtime"
  ],
  "presets": [
    "es2015",
    "react"
  ]
}

我的 webpack.config.js

var webpack = require('webpack');

var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js');

module.exports = {
  entry: {
    EventAdmin: './src/event_admin',
    EventRender: './src/event_render'
  },
  output: {
    path: '../public/js2',
    filename: '[name].js' // Template based on keys in entry above
  },
  externals: {
    // require("jquery") is external and available
    //  on the global var jQuery
    'jquery': 'jQuery'
  },
  plugins: [commonsPlugin],
  devtool: 'source-map',
  module: {
    loaders: [
      { test: /\.css$/, loader: 'style-loader!css-loader' },
      {
        test: /\.js$/,
        loader: 'babel-loader'
      },
    ]
  }
};

推荐答案

尝试在 loader之后添加 exclude:/ node_modules / :'babel-loader'。尝试在不排除 node_modules 的情况下运行运行时转换器时遇到了同样的问题。不过,我不知道潜在的问题。

Try adding exclude: /node_modules/ after loader: 'babel-loader'. I had the same problem when trying to run the runtime transformer without excluding node_modules. I am not aware of the underlying problem, though.

这篇关于Babel 6转换运行时:$ export不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 05:52