-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Modules not resolved with adapter-cloudflare (buffer, stream, util, crypto) #3564
Comments
I am unable to replicate. Tested in a brand new Svelte demo project. System info:
I also tried with node 16.3.0 in WSL without any errors. What are the contents of the project? Anything unusual in the config? Dependencies? |
Here is my svelte config, nothing fancy :
Maybe the problem is linked to one of my dependencies ?
Honestly no idea how to reproduce the bug other than that. The logs are not helping me to pinpoint the bug on any library with my current knowledge. The only things that I can think of is maybe the fact that the cloudflare adapter doesn't handle hooks.js or API routes (I have one POST request handler). But the package says that it supports all sveltekit features and those seems too basic to not be included in that phrasing. |
From the error message, it would certainly sound like the issue is that https://www.npmjs.com/package/jws uses Node APIs which are not available on Cloudflare. I imagine you would need to find another library that doesn't use these APIs. |
Do you have a recommendation on how can I find out which one(s) of my dependencies depends on jws ? (CTRL + F on my vscode doesn't find anything) |
That'd be EDIT: there are JWT libraries that use |
I just tested this library, it breaks as well with my cloudflare pages builds (and my local builds) :
I am going to find another way to solve my needs without using JWT. |
I think you could solve that by disabling prerendering? Looks like it tried to use the WebCrypto API while prerendering, which wouldn't work (and presumably you wouldn't want to do that anyway).
Hah, you very well might be happier for it. |
Disabling prerendering in svelte.config.js solves the issue. But it's probably smarter to let it activated because some pages might need it, and deal with the error in the I guess problem solved, Should I close the issue ? |
Yeah, sounds reasonable. Though if you're using the package in a hook then that will effectively disable prerendering. If you're using it in an endpoint or something then you should be able to work around it.
That's usually what happens when an issue is resolved, yes 🙂 |
@simcolin You can use the following libraries to create your own JWS functions. They are tested in SvelteKit projects that are deployed on Cloudflare Workers. The following code example generates parts of JWT using the
Custom functions can be written using the Web Crypto API and the TextEncoder. |
stripe uses these libraries, so can't use stripe on cloudfare? getting the same issues. |
I was able to get it to compile, using |
Describe the bug
The sveltekit build crash with current latest next versions of cloudflare adapter and sveltekit
Reproduction
use versions provided in system info
try to build
Logs
System Info
Severity
blocking an upgrade
Additional Information
standard node adapter compiles without any problem
using
{ platform: 'node' }
as build parameters for the cloudflare adapter fixes the build crash but break the cloudflare deploymentThe text was updated successfully, but these errors were encountered: