Closed bbigras closed 2 years ago
It already uses webcrypto under the hood since version 3. The error message would definetly help.. or i could create a own project and deploy to cloudflare once i got some free time
with svelte-kit build
:
> Using @sveltejs/adapter-cloudflare
✘ [ERROR] Could not resolve "crypto"
node_modules/.pnpm/zencrypt@0.0.6/node_modules/zencrypt/polyfill.js:11:29:
11 │ value: (await import('crypto')).webcrypto
╵ ~~~~~~~~
The package "crypto" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
[vite-plugin-svelte-kit] Build failed with 1 error:
node_modules/.pnpm/zencrypt@0.0.6/node_modules/zencrypt/polyfill.js:11:29: ERROR: Could not resolve "crypto"
> Build failed with 1 error:
node_modules/.pnpm/zencrypt@0.0.6/node_modules/zencrypt/polyfill.js:11:29: ERROR: Could not resolve "crypto"
node_modules/.pnpm/zencrypt@0.0.6/node_modules/zencrypt/polyfill.js:11:29: ERROR: Could not resolve "crypto"
at failureErrorWithLog (/home/bbigras/dev/tpg/test-kit/node_modules/.pnpm/esbuild@0.14.47/node_modules/esbuild/lib/main.js:1605:15)
at /home/bbigras/dev/tpg/test-kit/node_modules/.pnpm/esbuild@0.14.47/node_modules/esbuild/lib/main.js:1251:28
at runOnEndCallbacks (/home/bbigras/dev/tpg/test-kit/node_modules/.pnpm/esbuild@0.14.47/node_modules/esbuild/lib/main.js:1164:65)
at buildResponseToResult (/home/bbigras/dev/tpg/test-kit/node_modules/.pnpm/esbuild@0.14.47/node_modules/esbuild/lib/main.js:1249:7)
at /home/bbigras/dev/tpg/test-kit/node_modules/.pnpm/esbuild@0.14.47/node_modules/esbuild/lib/main.js:1358:14
at /home/bbigras/dev/tpg/test-kit/node_modules/.pnpm/esbuild@0.14.47/node_modules/esbuild/lib/main.js:666:9
at handleIncomingPacket (/home/bbigras/dev/tpg/test-kit/node_modules/.pnpm/esbuild@0.14.47/node_modules/esbuild/lib/main.js:763:9)
at Socket.readFromStdout (/home/bbigras/dev/tpg/test-kit/node_modules/.pnpm/esbuild@0.14.47/node_modules/esbuild/lib/main.js:632:7)
at Socket.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:315:12)
If you want to test, clone https://github.com/bbigras/svelte-crypto
and run npm run build
.
Okay, this should probably be fixed in version 3.0.6
, i've tested it with your repo and it get's build successfully.
It also seems to work when deployed as a Cloudflare page. Thank you very much!
I think it would need to use webcrypto. Not sure.
I can post the error message I get later or tomorrow.