webpack打包angularjs

打包前代码:

var __extends = (this && this.__extends) || function (d, b) {

for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());

};
// var Parent = require('../../../../js/controller/Parent.js');
var Base = (function (_super) {

__extends(Base, _super);
function Base() {
    _super.apply(this, arguments);
    console.log('子类');
}
return Base;

}(Parent));
angular.module('ViewApp')

.controller('Base', Base.constArg(Base));

module.exports = Base;

打包后代码:
....省略了开头的部分
/*/ (function(module, exports) {

/**

  • @fileoverview event log controller

  • @author zhaok.jy

  • @event_at 2016/11/24
    **/

var __extends = (this && this.__extends) || function (d, b) {

for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());

};
var Parent = require('../../../../js/controller/Parent.js');
var Base = (function (_super) {

__extends(Base, _super);
function Base() {
    _super.apply(this, arguments);
    console.log('子类');
}
return Base;

}(Parent));
angular.module('ViewApp')

.controller('Base', Base.constArg(Base));

module.exports = Base;

/*/ })
// ]);
注:constArg方法在父类中存在。
打包后运行总是报Base.constArg找不到。

阅读 2.5k
1 个回答

打包之前要将相互依赖的文件导入导出。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题