statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
27.21k stars 1.26k forks source link

Bug: package.json exports map incorrect #5123

Closed tkvw closed 3 days ago

tkvw commented 4 days ago

XState version

XState version 5

Description

I tried using xstate in the svelte repl (https://svelte.dev/playground/ffbd26371a294d11a437a74fbc064ad7?version=5.2.2), but it fails loading the xstate package. I think this is because the exports map specifies import to use the .mjs file, which reexports the commonjs modules.

The node specification (https://nodejs.org/api/packages.html#conditional-exports), says: import - matches when the package is loaded via import or import(), or via any top-level import or resolve operation by the ECMAScript module loader. Applies regardless of the module format of the target file. Always mutually exclusive with "require".

So I think this should be the esm bundle (xstate.esm.js).

Expected result

The repl to start.

Actual result

Did not start

Reproduction

https://svelte.dev/playground/ffbd26371a294d11a437a74fbc064ad7?version=5.2.2

Additional context

No response

Andarist commented 3 days ago

Our package.json#exports is fine and legal. I think that Svelte's REPL could improve its support for packages like this, see: https://github.com/sveltejs/svelte/pull/14344