tur*_*2oh 8 javascript polyfills internet-explorer-11 gulp babeljs
我已经通过添加插件拼凑支持IE11 transform-object-assign和array-includes现在我得到一个符号错误使用for of循环.不是一次一个地处理它们,我是否可以将babel polyfill工作到我的构建中并且将来证明它?
我已经阅读了几个相关的问题,但仍然不清楚我如何将babel-polyfill融入下面的gulp构建中:
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());
}
Run Code Online (Sandbox Code Playgroud)
编辑
我注意到 babel-polyfill 和 IE 存在问题,当我恢复到这个 npm 包“babel-polyfill”:“6.5.0”时,一切都开始正常工作
/编辑
你用的是browserify吗?您还需要babel-polyfill和 插件['transform-es2015-classes', { loose: true }]]
这是我的 IE 与 babel6 兼容性的 gulp 任务:
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'));
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9764 次 |
| 最近记录: |