-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
ReferenceError when using crypto
in Svelte 3 components
#278
Comments
|
Is this linked to #384 ? When trying to import Sveltekit specific modules in components (i.e. |
Not related I think. |
yeah, looks like it's part of svelte3 |
I see you originally ran this on Node 16. Does it work if you try Node 20? https://nodejs.org/api/globals.html#crypto_1 SvelteKit is supposed to polyfill |
Please reopen in case you still have the issue with Node 20 |
Describe the bug
We are using
crypto.randomUUID()
to generate unique IDs for input label associations on the fly in our Svelte 3<Input/>
component:Today, when porting our Storybook to Histoire, I noticed that the story isn't appearing in Histoire, and a Reference Error gets thrown in the terminal, when a Svelte 3 component uses
crypto
.I've attached a minimal repro, which has both
npm run story:dev
andnpm run dev
, to showcase that this error only occurs in Histoire, not the Svelte 3 app itself.A workaround for now is to check if crypto is defined and conditionally use a fallback:
I tried the same in Vue 3, and it seems to work fine there.
Reproduction
https://stackblitz.com/edit/histoire-svelte3-starter-vpjzy9?file=src/BaseButton.svelte
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: