I have Babel 6 working great with Gulp and Webpack. Now I need a polyfill to get IE8 support.
I installed babel-polyfill, but I canโt get it to work, and the documents and Google have not yet helped.
My Gulp task (including Webpack configuration):
gulp.task('webpack', function(callback) { var webpackConfig = { context: __dirname + '../../../js', entry: { homepage: [ 'babel-polyfill', './public/homepage/homepage.js' ] }, output: { path: __dirname + '../../../dist/public/scripts/', filename: '[name].bundle.js' }, module: { loaders: [ { loader: 'babel-loader', test: /\.js$/, // Only run .js files through Babel include: /js/, // Only include the /js dir query: { //plugins: ['transform-runtime'], // Disabled pending fix to https://github.com/babel/babel/issues/2954 presets: ['es2015'],//, 'stage-0' } } ] } }; webpack(webpackConfig, function(err, stats) { if (err) { throw new gutil.PluginError('webpack', err); } gutil.log('[webpack]', stats.toString({ // output options })); callback(); }); });
From the docs ( https://babeljs.io/docs/usage/polyfill/ ):
Using Node / Browserify / Webpack
To enable polyfill, you need to specify it at the top of the entry point in> your application.
required ("babel-polyfill");
Use in browser
Available from dist / polyfill.js in the babel-polyfill npm version. This should be included before all your compiled Babel code. You can either add it to the compiled code, or include it in front of it.
NOTE. Do not require this through a browser, etc., use babel-polyfill.
I tried just adding the polyfill.js file to the top of the page, but IE8 is still not happy with the compiled code for using the default keyword.
I also tried adding polyfill to the webpack process, according to http://jamesknelson.com/using-es6-in-the-browser-with-babel-6-and-webpack/ and other suggestions from google
What am I doing wrong?