Scrivo progetto con l'aiuto di TypeScript. Progetto diviso in molti moduli. Unisco tutti i moduli in un unico file con Webpack.Webpack e Typescript `__extends`
Per ogni classe di modulo, che si estende dalla classe padre, webpack ha aggiunto l'helper TypeScript __extends
. Come risultato - ho ricevuto molti codici ripetuti.
/***/ },
/* 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;
Quindi, un modo per risolvere il problema?
Questo è il comportamento predefinito del compilatore dattiloscritto ogni volta che rileva la parola chiave "estende". Poiché il compilatore non sa se si intende raggruppare l'output in un file o più, emette lo snippet ovunque si trovi la parola chiave. –
Dopo aver cercato su google ho trovato il flag '--noEmitHelpers', che disabilita gli helper. Ma ora ho bisogno di includere manualmente tutti gli helper di TS con Webpack https://www.npmjs.com/package/typescript-helpers. Sono a casa ora, ma domani provo a farlo con 'imports-loader' https://webpack.github.io/docs/shimming-modules.html#importing o con qualcos'altro. –