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

Set esbuild main fields to properly bundle Svelte components from npm #114

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

Prinzhorn
Copy link
Contributor

@Prinzhorn Prinzhorn commented Mar 1, 2022

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

Was about to open a bug report, but this seems to fix my problem:

I'm currently running into sveltejs/svelte#6600

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 version all the time and don't realize, because it will only run it conflicts when both use transitions I think**
@EMH333
Copy link
Owner

EMH333 commented Mar 1, 2022

Ah yep, I think I ran into this for one of my projects too. Thanks for the PR!

@EMH333 EMH333 merged commit ce561f8 into EMH333:main Mar 1, 2022
@Prinzhorn Prinzhorn mentioned this pull request Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants