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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposing Earcut as a module #126
Comments
Option 1 and Option 2 are not equivalent - the second one would most likely be breaking.
Looks slightly weird, but actually is 100% compatible with ESM and thus can be considered more "right" than not 馃槈
Depends on who do you ask really - default is actually pretty much a named export, just with a special support at the syntax level. Personally I wouldn't say that it is an anti-pattern - often it IMHO makes sense to export core util as default and low-level (for power users) stuff as named exports That being said - I don't have a strong opinion about which one is better in this particular case: 2, 3 or 4 (I would just really discourage you from using option 1). My advice is not to be afraid of breaking changes though, especially when they are so minor as exports shape change - you can just bump a major version and be done with it. Think about what you would have done right now - what API would you export - without looking back at what you have right now. |
Hi @mourner, this issue is almost 2 years old. I am curious if there is any plan to move forward with a fix, or if there is an ESM based solution for this that is suitable for use in production? |
I think I may have run into this with Vite? I'm a little lost in module options and don't have my head wrapped around this. But when you're using vite to build for production, it doesn't seem to play well with Earcut. You get a Module object with the earcut function on a .default property. Here's what |
@mrdoob Yes! And very soon. Started a branch recently here: https://github.com/mapbox/earcut/tree/modernize
The main stumbling block for me is deciding on what API to choose. Options:
Option 1
Pros:
Cons:
Option 2
Pros:
Cons:
earcut
function exported asearcut.default
, which is breaking and doesn't feel right.Option 3
Pros:
Cons:
earcut.earcut(...)
isn't great.deviation
andflatten
names aren't clear out of context (if you import them without namespacing).Option 4
Pros:
Cons:
Thoughts, suggestions?
Ref #102 (@Andarist sorry for not responding earlier!)
The text was updated successfully, but these errors were encountered: