软件腐烂。我对一个三年前的 GitHub 项目做了一个小改动,由于自动安全补丁,重建失败了。除了默认导入失败外,一切都已修复。
错误是:
ERROR in ./src/HeatMapTable.js 340:20-27
export 'default' (imported as 'HeatMap') was not found in 'jsheatmap' (module has no exports)
相关代码如下:
main.js
import HeatMap, { Style } from "jsheatmap"; //eslint-disable-line no-unused-vars
jhheatmap, index.ts
class Sterno {...}
...
export { Style, Sterno as default }
如果我查看节点模块中的内容,jsheatmap/lib/index.js 文件显示:
var Sterno = /** @class */ (function () {...}
...
exports.default = Sterno;
如果我没有记错我的 CommonJS,上面的导出应该与 main.js.
中使用的 ECMAScript 导入兼容这是我的 tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"outDir": "lib",
"rootDir": "src",
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true
},
"exclude": [
"test"
]
}
package.json
{
"name": "jsheatmap",
"version": "1.2.3",
"description": "Generates heat map data",
"main": "lib/index.js",
"type": "module",
"scripts": {
"start": "npm run build:live",
"build": "tsc -p .",
"build:live": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts",
"test": "mocha -r ts-node/register test/**/*.ts"
},...