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

Failed to set @use-gesture/core/action as external dependency #832

Open
svnhub opened this issue May 16, 2024 · 2 comments
Open

Failed to set @use-gesture/core/action as external dependency #832

svnhub opened this issue May 16, 2024 · 2 comments
Labels
browser Not working in Browser

Comments

@svnhub
Copy link

svnhub commented May 16, 2024

Failing module

https://esm.sh/@use-gesture/[email protected]/ accidentally bundles actions.js from
https://esm.sh/@use-gesture/[email protected]/actions
which means that variables set on the imported actions module are not visible inside the bundled version of it when seen from core.

Using
https://esm.sh/@use-gesture/[email protected]/?external=@use-gesture/core/actions
or
https://esm.sh/*@use-gesture/[email protected]
does not fix this.

Using ?no-bundle it is clear that core imports https://esm.sh/v135/@use-gesture/[email protected]/es2022/dist/actions-fe213e88.esm.js which is a minified version of @use-gesture/core/actions an hence even without bundling it is not possible to share variables since the source is different and when loaded it will end up in a different module instance.

Additional info

  • esm.sh version: v135
  • Browser version: any
@svnhub svnhub added the browser Not working in Browser label May 16, 2024
@svnhub svnhub changed the title Failed to set @use-gesture/core/action as external dependency Failed to set @use-gesture/core/action as external dependency May 16, 2024
@svnhub
Copy link
Author

svnhub commented May 17, 2024

Just verified the bug by building a working version locally where both @use-gesture/core and @use-gesture/core/actions reference the same external actions-xxxxxxxxx.esm.js module file.

So to simplify: The issue is that @use-gesture/core doesn't consider actions.js to be part of @use-gesture/core/actions but instead part of itself and by default the bundler inlines the code from it regardless of whether it was added as external to the esm.sh CDN URL or not.
When using both @use-gesture/core and @use-gesture/core/actions in your app you then end up with two versions of actions.js - one inlined in core and one as module, causing the app to break.

@ije
Copy link
Member

ije commented May 17, 2024

Screenshot 2024-05-17 at 18 27 03

i just found there is a package.json in the actions directory, the current server can't not handle it correctly, next version this will be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser Not working in Browser
Projects
None yet
Development

No branches or pull requests

2 participants