这是Babel错误地编译的代码
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module and set browser global
define(['underscore', 'backbone', 'jquery'], function (_, Backbone, $) {
return (root.Backbone = factory(_, Backbone, $));
});
} else if (typeof exports !== 'undefined' && typeof require !== 'undefined') {
module.exports = factory(require('underscore'), require('backbone'), require('jquery'));
} else {
// Browser globals
root.Backbone = factory(root._, root.Backbone, root.jQuery);
}
}(this, function (_, Backbone, $) {
最后的 this 参数未定义
我正在将babel 6.26.3与以下.babelrc一起使用
{
"presets": [
"react",
"es2015",
"es2017",
"stage-1"
],
"plugins": [
"react-hot-loader/babel",
"transform-decorators-legacy",
"add-module-exports",
"transform-runtime"
]
}
我不知道为什么会这样。我看了看 this similar issue,但解决方案均无效,无法设置模块:false会破坏其余的构建