【发布时间】:2021-09-30 15:17:36
【问题描述】:
我在项目中有 2 个 tslib 版本
| +-- @typescript-eslint/eslint-plugin@3.10.1
| | `-- tsutils@3.21.0
| | `-- tslib@1.14.1
| `-- eslint@6.8.0
| `-- inquirer@7.3.3
| `-- rxjs@6.6.7
| `-- tslib@1.14.1 deduped
`-- enzyme@3.9.0
`-- cheerio@1.0.0-rc.10
`-- tslib@2.3.0
webpack 将 Cheerio 的使用解析为错误的 tslib 1.14 版本,导致运行时错误 tslib_1.__spreadArray is not a function at
/***/ "./node_modules/cheerio/lib/static.js":
/*!********************************************!*\
!*** ./node_modules/cheerio/lib/static.js ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.merge = exports.contains = exports.root = exports.parseHTML = exports.text = exports.xml = exports.html = void 0;
var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
我能以某种方式追踪 webpack 模块的分辨率吗? 会因为 resolve.modules 而发生吗?
resolve: {
unsafeCache: true,
aliasFields: ["browser"],
mainFields: ["module", "jsnext:main", "browser", "main"],
modules: [
"./node_modules",
path.resolve(context),
path.resolve(context, "node_modules"),
],
【问题讨论】:
-
你最后解决了吗?提前谢谢你和问候
标签: javascript typescript webpack