Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 851
Ted Avery Avatar asked Mar 30 '16 15:03

Ted Avery


People also ask

What does babel transform runtime do?

A plugin that enables the re-use of Babel's injected helper code to save on codesize.

Is babel runtime dev dependency?

The short answer is yes: @babel/runtime (and @babel/plugin-transform-runtime ) is intended to be treated as a dependency.

What is babel transform?

babel.transform(code: string, options?: Object, callback: Function) Transforms the passed in code . Calling a callback with an object with the generated code, source map, and AST.


1 Answers

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.

like image 69
Pierre Wahlgren Avatar answered Oct 09 '22 01:10

Pierre Wahlgren