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

Build failed when compiling with adapter-cloudflare #31

Closed
kroniapp opened this issue Sep 7, 2022 · 5 comments · Fixed by #34
Closed

Build failed when compiling with adapter-cloudflare #31

kroniapp opened this issue Sep 7, 2022 · 5 comments · Fixed by #34
Labels
bug Something isn't working sveltekit version 2.x

Comments

@kroniapp
Copy link

kroniapp commented Sep 7, 2022

Starting from version 2.0.0, in Sveltekit I cannot compile with adapter-cloudflare.

The error I am receiving is:

Error: Build failed with 2 errors:
.svelte-kit/output/server/chunks/lists.js:2:14: ERROR: Could not resolve "util"
.svelte-kit/output/server/chunks/lists.js:3:14: ERROR: Could not resolve "crypto"

I'm using Sveltekit with SSR disabled, so no Node packages are allowed.

From what I found reading the source code, I think the problem is with the new "cyrup" dependency added from version 2.0.0, which imports the two Node packages.

@MacFJA
Copy link
Owner

MacFJA commented Sep 7, 2022

Hello,

Can you try with the version 2.1.0 ?
This version should fix the issue require "util" and require "crypto"

@MacFJA MacFJA added bug Something isn't working sveltekit version 2.x labels Sep 7, 2022
@kroniapp
Copy link
Author

kroniapp commented Sep 8, 2022

Yes, I also tried version 2.1.0, but it give me the same error.

I created a project to reproduce the error https://stackblitz.com/edit/sveltejs-kit-template-default-tqmyfx?file=src/routes/+page.svelte

I also want to thank you for this library, good job!

@kroniapp
Copy link
Author

Do you have the time to look at this issue? It's blocking my deployments

@MacFJA
Copy link
Owner

MacFJA commented Sep 13, 2022

I try many configurations, tricks, but I can't achieve to have the compilation work.

I have an ugly workaround (which is editing the library dist file before building) but it's not a very practical or usable solution in an automated pipeline.


Others solutions that I have are:

  • Make the crypto lib dependency optional, but require extra work to check is the dependency is installed or not (+ BC break).
  • Make the encrypted storage a separate package, but that add more steps and workflow for publishing (+ BC break).
  • Change the crypto lib dependency to crypto-es, but we loose native function as it's a pure JS implementation, so probably less performant.

(I will probably go with the last one, as it introduce the fewer changes for users)

@MacFJA
Copy link
Owner

MacFJA commented Oct 10, 2022

@kroniapp I just publish the version 2.2.0 that fix the error.
It took way longer than I have expected, sorry about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sveltekit version 2.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants