Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript CommonJS not exported properly #131

Open
HcgRandon opened this issue Oct 16, 2022 · 2 comments
Open

Typescript CommonJS not exported properly #131

HcgRandon opened this issue Oct 16, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@HcgRandon
Copy link

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

@Patashu Patashu added the bug Something isn't working label Oct 16, 2022
@Patashu
Copy link
Owner

Patashu commented Oct 16, 2022

Thanks, I'm not very strong at Typescript so I appreciate the help if you get time for it.

@bbugh
Copy link
Contributor

bbugh commented Feb 28, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants