Babel 6 transform-runtime: $export is not a functi

2019-01-22 17:09发布

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?

Here is my .babelrc:

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

And my 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'
      },
    ]
  }
};

enter image description here

7条回答
看我几分像从前
2楼-- · 2019-01-22 18:14

You can try replace "exclude" by "include", following the recomendations from documentation.

Try to prefer "include" when possible...

This worked for me.

{
  "test": /\.js/,
  "loader": "babel",
  "include": [path.resolve(__dirname, './src')]
}
查看更多
登录 后发表回答