GoogleChromeLabs/jsbi

CJS Module will not work on browser due to different JSBI's build target

thanpolas opened this issue · 3 comments

JSBI has different builds depending on the environment:

  "main": "dist/jsbi-cjs.js",
  "module": "dist/jsbi.mjs",
  "browser": "dist/jsbi-umd.js",

when the "module" or "browser" targets are used the CJS modules that depend on JSBI will break with an error of JSBI.BigInt is not a Function.

What would you advise so that a CJS library can safely work with JSBI in all environments?

Believe there is relation to issue #42, which also happens to be the answer to life the universe and everything

image

yea, as I suspected, the BigInt function on the jsbi-umd module can be found on the path jsbi.default.BigInt.

I will work around that on my library to do heuristics and figure out where to find the expected functions from the JSBI package as I don't expect this to be resolved.

It's interesting where we've come with Javascript and interoperability between packages.

I think this probably needs to be fixed similar to #69 - specifically,

exports: 'named',
needs to be set to "default", not "named".

I'll send a PR if I can validate this will actually fix your issue.