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

问题描述

限时删除!!

我正在尝试合并 Babel 的转换运行时以使我的代码与 IE9 兼容.但自从集成它后,代码甚至无法在 Chrome 上运行.我在 es6.object.define-property.js:3 上收到错误 Uncaught TypeError: $export is not a function.在我的 .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: 'babel-loader' 之后添加 exclude:/node_modules/.我在不排除 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 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 12:16