You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry if i'm not following a template but this is a bit of a special case...the import actually succeed but i think the resulting JS file is unproperly bundled.
So what i'm doing is i'm compiling a svelte component into a JS file. It looks something like this.
however here's where the problem arise. As you can see my main js file it's importing hydrate from svelte (which is the root entry point exposed by svelte) and the Component.js it's importing the client runtime from svelte/internal/client, another entry point exposed by svelte.
Those two modules exposed by svelte both import a third module that expose an export hydrating and some other utilities. However when accessing the module bundled by esm.sh this third shared module is bundled separately in each module so the aforementioned hydrating variable is just a local variable for both modules. This obviously breaks a lot of stuff and the whole thing cease to work.
I can fix this with a slight change to the import map
ships the library completely unbundled leading to a lot of http requests.
The best option would be for esm.sh to smartly externalize a module if it's shared by multiple exposed entry points of a library. Do you think it could be feasible? Do you see any other solution to this problem?
The text was updated successfully, but these errors were encountered:
I think it's probably simpler than checking the dependency tree — just pass the entries in package.exports to esbuild as entryPoints and enable splitting: true, and it should do the work for you
Sorry if i'm not following a template but this is a bit of a special case...the import actually succeed but i think the resulting JS file is unproperly bundled.
So what i'm doing is i'm compiling a svelte component into a JS file. It looks something like this.
then i'm importing this component and
hydrate
fromsvelte
in my main js filei can setup an importmap to map this work like this
however here's where the problem arise. As you can see my main js file it's importing
hydrate
fromsvelte
(which is the root entry point exposed by svelte) and theComponent.js
it's importing the client runtime fromsvelte/internal/client
, another entry point exposed by svelte.Those two modules exposed by svelte both import a third module that expose an export
hydrating
and some other utilities. However when accessing the module bundled byesm.sh
this third shared module is bundled separately in each module so the aforementionedhydrating
variable is just a local variable for both modules. This obviously breaks a lot of stuff and the whole thing cease to work.I can fix this with a slight change to the import map
but this
The best option would be for
esm.sh
to smartly externalize a module if it's shared by multiple exposed entry points of a library. Do you think it could be feasible? Do you see any other solution to this problem?The text was updated successfully, but these errors were encountered: