我使用TypeScript编写项目。 项目分成许多模块。 我使用Webpack将所有模块捆绑到一个文件中。
对于每个继承自父类的模块类,Webpack都会添加TypeScript __extends
助手。
结果是 - 我得到了许多重复的代码。
/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
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 DeepExtend_1 = __webpack_require__(6);
//...
exports.SafariDetector = SafariDetector;
/***/ },
/* 25 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
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 DeepExtend_1 = __webpack_require__(6);
//...
exports.SafariMobileDetector = SafariMobileDetector;
那么,有什么方法可以解决这个问题吗?
--noEmitHelpers
标志,它可以禁用辅助程序。但现在我需要手动使用 Webpack 包含所有的 TS 辅助程序 https://www.npmjs.com/package/typescript-helpers。 我现在在家里,但明天我会尝试使用imports-loader
https://webpack.github.io/docs/shimming-modules.html#importing 或其他方法来完成这个任务。 - Качалов Тимофей