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

[@xstate/svelte] Missing ESM exports #2642

Closed
f-elix opened this issue Sep 13, 2021 · 2 comments · Fixed by #3209
Closed

[@xstate/svelte] Missing ESM exports #2642

f-elix opened this issue Sep 13, 2021 · 2 comments · Fixed by #3209

Comments

@f-elix
Copy link
Contributor

f-elix commented Sep 13, 2021

Description
Right now, the distributed package of @xstate/svelte only exports CJS and this caused some problem after an update in SvelteKit (sveltejs/kit#2418).

Expected Result
In any case, Xstate core exports both CJS and ESM. Is there any reason why it isn't the same with @xstate/svelte? If there isn't any, I think it should have an ESM export.

@davidkpiano
Copy link
Member

cc. @farskid @Andarist

@schibrikov
Copy link

I also have a problem there. I'm using SvelteKit and xstate with @xstate/svelte and it causes problems when building for e.g. cloudflare where SvelteKit tries to bundle the application with esbuild.
I guess the problem is svelte bindings are compiled for commonjs which results in something like this inside:
var xstate_1 = require("xstate");
After rollup processes the application it's becoming this:
import require$$1, { createMachine } from "xstate"; (because the input was commonjs like)
So when esbuild comes into play it's looking for default export in xstate which is not present.

I'll try looking into it and maybe make a PR with ESM target.

schibrikov pushed a commit to schibrikov/xstate that referenced this issue Apr 8, 2022
Andarist added a commit that referenced this issue Apr 27, 2022
* Add ESM build to @xstate/svelte package, fixes #2642

* tweaks

Co-authored-by: Mateusz Burzyński <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants