最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how can I use babel polyfill to support all IE11 issues with gulp - Stack Overflow

programmeradmin6浏览0评论

I've been piecing together support for IE11 by adding plugins for transform-object-assign and array-includes and now I'm getting a symbol error for using for of loops. Instead of just tackling them one at a time, is it possible for me to work babel polyfill into my build below and future proof it?

I've read several related questions but still am not clear on how I'd fit babel-polyfill into the gulp build below:

return gulp.src(input)  // Grab the input files
        .pipe($.babel({
            presets: ['es2015'], // transform ES6 to ES5 with Babel
            plugins: ['transform-object-assign','array-includes']

        }))
        .pipe($.concat(outputFile))
        .pipe($.uglify({
            press: {
                drop_debugger:  true
            }
        }))
        .pipe(gulp.dest(paths.output))  // Output file destination
        .pipe($.connect.reload());
}

I've been piecing together support for IE11 by adding plugins for transform-object-assign and array-includes and now I'm getting a symbol error for using for of loops. Instead of just tackling them one at a time, is it possible for me to work babel polyfill into my build below and future proof it?

I've read several related questions but still am not clear on how I'd fit babel-polyfill into the gulp build below:

return gulp.src(input)  // Grab the input files
        .pipe($.babel({
            presets: ['es2015'], // transform ES6 to ES5 with Babel
            plugins: ['transform-object-assign','array-includes']

        }))
        .pipe($.concat(outputFile))
        .pipe($.uglify({
            press: {
                drop_debugger:  true
            }
        }))
        .pipe(gulp.dest(paths.output))  // Output file destination
        .pipe($.connect.reload());
}
Share Improve this question edited Mar 28, 2016 at 15:26 turbo2oh asked Mar 28, 2016 at 15:02 turbo2ohturbo2oh 2,8796 gold badges36 silver badges47 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

Edit

I noticed an issue with babel-polyfill and IE, when i reverted to this npm package "babel-polyfill": "6.5.0" everything started working normally

/Edit

Are you using browserify? Also you'll need the babel-polyfill and the plugin ['transform-es2015-classes', { loose: true }]]

heres my gulp task for IE patibility with babel6:

gulp.task('pile', () => {
    browserify('./js/script.js', { debug: true })
    .add(require.resolve('babel-polyfill'))
    .transform(babelify.configure({presets: ['es2015'], plugins:['transform-es2015-classes', { loose: true }]]}))
    .bundle()
    .on('error', util.log.bind(util, 'Browserify Error'))
    .pipe(source('script.js'))
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(uglify({ mangle: false }))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest('./build'));
  });
发布评论

评论列表(0)

  1. 暂无评论