-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
dist not commonjs compatible #137
Comments
Same problem here, can't update to 3.x until this is fixed |
@Niek: note that nothing is "broken", and so doesn't need a "fix": this is an enhancement request. The new library was explicitly released as an ES module because everything has had support for ES modules for several versions now (all modern browsers have supported them for many, many versions, and Node's supported them for four versions, the latest 2 of which are native rather than through a runtime flag). @kumavis if you can let me know how to make hybrid packages that work, I can look at whether that's something that can easily be added here (as far as I know the |
@Pomax sorry if my comment sounded too harsh. ES is definitely the way to go, but there seems to be some issue with the package being identified as CJS. I'm trying to get v3 working with https://github.com/Xetera/ghost-cursor (typescript, importing this module) but it fails with: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: node_modules/bezier-js/dist/bezier.js
require() of ES modules is not supported.
require() of node_modules/bezier-js/dist/bezier.js from lib/math.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename bezier.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from node_modules/bezier-js/package.json. |
Hi @Niek, the new bezier-js V3 is a breaking change from v2 from the TypeScript typings. So if you’re using TypeScript, you may want to keep using v2 until someone writes typings for v3. |
Ahh, yes if we're talking about typescript, that's a kettle of fish I've no experience with. Having said that: you should not be using |
Line 6 in f238747
|
hm, let's see what happened there. |
Right, well: I have no idea why Thanks for pointing this out, I've updated both files and pushed a v3.1.0 to NPM with those changes |
Is this not typescript compatible quite yet? |
Depends on what you mean with "compatible"? TS is a superset of JS, so all JS is by definition TS compatible. If you mean "still doesn't have typing": no, because I write plain JS, not TS. |
closing this, since a version with fix was pushed out quite a while ago. |
The typings are out of date. Not your fault, like you said. But on top of that I get a “Bezier not exported from bezier-js”, even when just declaring the module in my index.d.ts No worries though, as I ended up just copying the functionality I needed and rewriting it a bit locally in my project and adding types. Thank you for the awesome library btw! |
If the library doesn't work as a normal JS import, that's 100% a bug and if you can file a bug with STR for that, that'd be appreciated. |
@Pomax Gotcha, thank you. Maybe at some later time. However, my immediate needs are taken care of and fixing this bug will not assist me in my own project at this time. At some later point in the project, I may wish to switch back to the full lib. At that point I will assist in identifying/fixing the possible bug and updating/maintaining the typings. |
you don't need to fix it. I just need to have an issue for it so it's known and someone (probably me) can fix it. Because this is open source: if you know there's a problem, then at least report it, not "for your benefit", but "for everyone's benefit" =) |
@Pomax I very well could just be doing something dumb (i.e., a bad TS config or something). I'll try to upload a minimal reproducible codebase sometime today or tomorrow and create a ticket. I didn't do anything crazy, standard create-react-app typescript template. Since the last release was April, if I wasn't doing something dumb I'd assume someone would have caught it by now. |
dist contains export statement here https://github.com/Pomax/bezierjs/blob/master/dist/bezier.js#L2236
possibly a mistake? it is possible to build "hybrid packages" that are compatible with both esm and commjs
related vasturiano/force-graph#152
The text was updated successfully, but these errors were encountered: