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

时间:2016-03-28 15:02:29

标签: javascript gulp internet-explorer-11 babeljs polyfills

通过添加transform-object-assignarray-includes的插件,我一直在拼凑对IE11的支持,现在我使用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());
}

1 个答案:

答案 0 :(得分:0)

修改

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

<强> /修改

您使用的是browserify吗?此外,您还需要var app = angular.module('app', []); app.controller('demoController', ['$scope', function ($scope) { $scope.input = []; $scope.masters = [ { "name": "Wittgenstein", "thoughts": ["thought 1", "thought 2", "thought 3"] }, { "name": "King", "thoughts": ["thought 1", "thought 2", "thought 3"] }]; $scope.add = function(index) { $scope.masters[index].thoughts.push($scope.input[index]); $scope.input[index] = ''; }; $scope.remove = function(master, index) { master.thoughts.splice(index, 1); }; }]); 和插件babel-polyfill

继承了我与babel6的IE兼容性的gulp任务:

['transform-es2015-classes', { loose: true }]]