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' }, ] } };
A plugin that enables the re-use of Babel's injected helper code to save on codesize.
The short answer is yes: @babel/runtime (and @babel/plugin-transform-runtime ) is intended to be treated as a dependency.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With