esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

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

Open svnhub opened this issue 1 year ago • 2 comments

Failing module

  • GitHub: https://github.com/pmndrs/use-gesture/tree/main
  • npm: https://www.npmjs.com/package/@use-gesture/core

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 avatar May 16 '24 14:05 svnhub

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.

svnhub avatar May 17 '24 10:05 svnhub

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

ije avatar May 17 '24 10:05 ije