我如何使用babel polyfill来支持gullow的所有IE11问题



我一直在通过添加transform-object-assignarray-includes的插件来拼凑对IE11的支持,现在我在使用for of循环时遇到了一个符号错误。与其一次处理一个,我有可能在下面的构建中使用babel polyfill并经得起未来的考验吗?

我已经阅读了几个相关的问题,但仍然不清楚如何将babel polyfill放入下面的gull构建中:

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({
            compress: {
                drop_debugger:  true
            }
        }))
        .pipe(gulp.dest(paths.output))  // Output file destination
        .pipe($.connect.reload());
}

编辑

我注意到babel polyfill和IE的一个问题,当我恢复到这个npm包"babel polyfill"时:"6.5.0"所有东西都开始正常工作

/编辑

你在用browserfy吗?此外,您还需要babel-polyfill和插件['transform-es2015-classes', { loose: true }]]

这是我与babel6:兼容IE的艰巨任务

gulp.task('compile', () => {
    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'));
  });

最新更新