Software decays over time. After making a small modification to a GitHub project that was three years old, the rebuild failed due to automatic security patches. I managed to fix everything except for an issue with a default import.
The specific error message is:
ERROR in ./src/HeatMapTable.js 340:20-27
export 'default' (imported as 'HeatMap') was not found in 'jsheatmap' (module has no exports)
Here is the relevant code snippet:
Main.js
import HeatMap, { Style } from "jsheatmap"; //eslint-disable-line no-unused-vars
Jsheatmap, index.ts
class Sterno {...}
...
export { Style, Sterno as default }
When looking at the jsheatmap/lib/index.js file in node-modules, it shows:
var Sterno = /** @class */ (function () {...}
...
exports.default = Sterno;
Based on my knowledge of CommonJS, this export should be compatible with the ECMAScript import used in Main.js.
This is the content of my tsconfig.json file:
{
"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"
},...