Typescript CommonJS not exported properly
When trying to import this lib from a nodejs typescript project in module: commonjs mode it is unusable.
I Import via import Decimal from 'break_eternity.js';.
Any call to new Decimal(); results in TypeError: break_eternity_js_1.default is not a constructor. I have some experience with these issues myself and will attempt to debug when I have time, but thought I should track it here sooner then later
Thanks, I'm not very strong at Typescript so I appreciate the help if you get time for it.
The bili lib I originally set up for TS looks to have been abandoned, and we have esbuild that can do all of the things now. Might be worth switching over to it.
@HcgRandon it's been a while but if you're still using this lib, could you try it with esbuild?
// esbuild.ts
import esbuild, { BuildOptions } from "esbuild";
const options: BuildOptions = {
entryPoints: ["src/index.ts"],
outdir: "lib",
bundle: true,
sourcemap: true,
logLevel: "info"
}
// cjs
esbuild
.build({
...options,
platform: "node",
outExtension: { ".js": ".cjs.js" },
target: ["node10.4"],
})
.catch(() => process.exit(1));
And then run with
$ npx ts-node esbuild.ts