Set esbuild main fields to properly bundle Svelte components from npm #114
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Was about to open a bug report, but this seems to fix my problem:
I'm currently running into sveltejs/svelte#6600 (also sveltejs/svelte#3165 in the past)
Basically I want to use a Svelte component from npm, but esbuild will look at
main
/browser
and include the compiled version. But it needs to load the raw Svelte code. So you end up with two version of Svelte in the same project, causing the crash.See https://github.com/zerodevx/svelte-toast/blob/281f95da2b6252d6756c053e302c6bd2a645ddb7/package.json#L6
And of course esbuild already has a solution, as always: https://esbuild.github.io/api/#main-fields
FWIW people might be bundling multiple Svelte versions all the time and don't realize, because it will only run into conflicts when both use transitions I think