Pomax / bezierjs

A nodejs and client-side library for (cubic) Bezier curve work
MIT License
1.7k stars 230 forks source link

_bezierJs.default is not a constructor in codesandbox #174

Closed mdiegoli closed 2 years ago

mdiegoli commented 2 years ago

Hi, I'm using bezierjs, via npm, in a codesandbox project. When I'm doing

const curve = new Bezier(102, 33, 16, 99, 101, 129, 132, 173);

I have

TypeError _bezierJs.default is not a constructor. I have to use a different class or something else?

This is the codesandbox link

https://codesandbox.io/s/modest-banzai-lv747?file=/src/index.js:6668-6730

Thank you

Pomax commented 2 years ago

Given that there is no _bezierJs.default in the code anywhere (neither the real code, which browsers can load just fine because it's modern ESM JS, nor the legacy CJS version), I don't think I'm the right person to ask about this. It sounds like npm is taking the already wrong version and then further transpiling it for use in a browser, which is something whoever works on that "run in the browser" feature over on npm should have a look at.

Pomax commented 2 years ago

See if 6.1.0 now works for you. I added a browser field to the package.json so that hopefully nothing gets further transpiled.

mdiegoli commented 2 years ago

No, the problem still remain. Probably it's a codesandbox problem?

mdiegoli commented 2 years ago

Ok, it works on Codpen!

https://codepen.io/morticcino/pen/VwrbPoR

Many thanks

Pomax commented 2 years ago

I guess codesandbox runs transpiles even when it really shouldn't. Might be worth reporting to them so that they can fix that.