delucis/astro-og-canvas
[Feature request]: Support @astrojs/cloudflare SRR Adapter
Open
#35 opened on Nov 17, 2023
help wanted
Repository metrics
- Stars
- (272 stars)
- PR merge metrics
- (PR metrics pending)
Description
Hi,
This package is awesome!! But it is incompatible with @astrojs/cloudflare SRR Adapter. When you deploy it I recieve this error:
In cloudflare
16:57:36.710 | ✘ [ERROR] Could not resolve "node:fs/promises"
-- | --
16:57:36.710 |
16:57:36.710 | dist/$server_build/chunks/pages/__73e63732.mjs:2:15:
16:57:36.710 | 2 │ import fs from 'node:fs/promises';
16:57:36.710 | ╵ ~~~~~~~~~~~~~~~~~~
16:57:36.711 |
16:57:36.711 | The package "node:fs/promises" 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.
16:57:36.711 |
16:57:36.711 | ✘ [ERROR] Could not resolve "node:module"
16:57:36.711 |
16:57:36.711 | dist/$server_build/chunks/pages/__73e63732.mjs:6:30:
16:57:36.711 | 6 │ import { createRequire } from 'node:module';
16:57:36.711 | ╵ ~~~~~~~~~~~~~
16:57:36.712 |
16:57:36.712 | The package "node:module" 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.
16:57:36.712 |
16:57:36.719 | ✘ [ERROR] Could not resolve "crypto"
16:57:36.719 |
16:57:36.720 | node_modules/deterministic-object-hash/dist/index.js:7:25:
16:57:36.720 | 7 │ const crypto_1 = require("crypto");
16:57:36.720 | ╵ ~~~~~~~~
16:57:36.720 |
16:57:36.720 | 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.
16:57:36.720 |
16:57:36.739 | ✘ [ERROR] Could not resolve "path"
16:57:36.740 |
16:57:36.740 | node_modules/canvaskit-wasm/bin/canvaskit.js:153:20:
16:57:36.740 | 153 │ if(za)Aa=ya?require("path").dirname(Aa)+"/":__dirname+"/",Fa=()=>...
16:57:36.740 | ╵ ~~~~~~
16:57:36.740 |
16:57:36.741 | The package "path" 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.
16:57:36.741 |
16:57:36.741 | ✘ [ERROR] Could not resolve "fs"
16:57:36.741 |
16:57:36.741 | node_modules/canvaskit-wasm/bin/canvaskit.js:153:82:
16:57:36.741 | 153 │ ...+"/",Fa=()=>{Ea\|\|(fs=require("fs"),Ea=require("path"))},Ba=fun...
16:57:36.742 | ╵ ~~~~
16:57:36.742 |
16:57:36.742 | The package "fs" 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.
16:57:36.742 |
16:57:37.099 | error Could not resolve "node:fs/promises"
16:57:37.099 | File:
16:57:37.100 | dist/$server_build/chunks/pages/__73e63732.mjs:2:15
16:57:37.100 | Code:
16:57:37.100 | 1 \| import { deterministicString } from 'deterministic-object-hash';
16:57:37.100 | > 2 \| import fs from 'node:fs/promises';
16:57:37.101 | \| ^
16:57:37.101 | 3 \| import path from 'node:path';
16:57:37.101 | 4 \| import { _ as __vite_glob_0_0 } from '../prerender_6a77773e.mjs';
16:57:37.101 | 5 \| import init from 'canvaskit-wasm';
16:57:37.101 | Stacktrace:
16:57:37.101 | Error: Build failed with 5 errors:
16:57:37.102 | dist/$server_build/chunks/pages/__73e63732.mjs:2:15: ERROR: Could not resolve "node:fs/promises"
16:57:37.102 | dist/$server_build/chunks/pages/__73e63732.mjs:6:30: ERROR: Could not resolve "node:module"
16:57:37.102 | node_modules/canvaskit-wasm/bin/canvaskit.js:153:20: ERROR: Could not resolve "path"
16:57:37.102 | node_modules/canvaskit-wasm/bin/canvaskit.js:153:82: ERROR: Could not resolve "fs"
16:57:37.102 | node_modules/deterministic-object-hash/dist/index.js:7:25: ERROR: Could not resolve "crypto"
16:57:37.102 | at failureErrorWithLog (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:1650:15)
16:57:37.102 | at /opt/buildhome/repo/node_modules/esbuild/lib/main.js:1059:25
16:57:37.103 | at /opt/buildhome/repo/node_modules/esbuild/lib/main.js:1004:52
16:57:37.103 | at buildResponseToResult (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:1057:7)
16:57:37.103 | at /opt/buildhome/repo/node_modules/esbuild/lib/main.js:1086:16
16:57:37.103 | at responseCallbacks.<computed> (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:703:9)
16:57:37.103 | at handleIncomingPacket (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:763:9)
16:57:37.103 | at Socket.readFromStdout (/opt/buildhome/repo/node_modules/esbuild/lib/main.js:679:7)
16:57:37.103 | at Socket.emit (node:events:514:28)
16:57:37.104 | at addChunk (node:internal/streams/readable:324:12)
16:57:37.104 |
16:57:37.128 | Failed: Error while executing user command. Exited with error code: 1
16:57:37.137 | Failed: build command exited with code: 1
16:57:38.184 | Failed: error occurred while running build command
In local build
X [ERROR] Could not resolve "node:fs/promises"
dist/$server_build/chunks/pages/__b54f80a9.mjs:2:15:
2 │ import fs from 'node:fs/promises';
╵ ~~~~~~~~~~~~~~~~~~
The package "node:fs/promises" 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.
X [ERROR] Could not resolve "node:module"
dist/$server_build/chunks/pages/__b54f80a9.mjs:6:30:
6 │ import { createRequire } from 'node:module';
╵ ~~~~~~~~~~~~~
The package "node:module" 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.
X [ERROR] Could not resolve "crypto"
node_modules/deterministic-object-hash/dist/index.js:7:25:
7 │ const crypto_1 = require("crypto");
╵ ~~~~~~~~
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.
X [ERROR] Could not resolve "path"
node_modules/canvaskit-wasm/bin/canvaskit.js:153:20:
153 │ if(za)Aa=ya?require("path").dirname(Aa)+"/":__dirname+"/",Fa=()=>{Ea||(fs=require("fs"),Ea=require("...
╵ ~~~~~~
The package "path" 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.
X [ERROR] Could not resolve "fs"
node_modules/canvaskit-wasm/bin/canvaskit.js:153:82:
153 │ ...(Aa)+"/":__dirname+"/",Fa=()=>{Ea||(fs=require("fs"),Ea=require("path"))},Ba=function(a,b){Fa();a...
╵ ~~~~
The package "fs" 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.
error Could not resolve "node:fs/promises"
dist/$server_build/chunks/pages/__b54f80a9.mjs:6:30: ERROR: Could not resolve "node:module"
node_modules/canvaskit-wasm/bin/canvaskit.js:153:20: ERROR: Could not resolve "path"
node_modules/canvaskit-wasm/bin/canvaskit.js:153:82: ERROR: Could not resolve "fs"
node_modules/deterministic-object-hash/dist/index.js:7:25: ERROR: Could not resolve "crypto"
at failureErrorWithLog (E:\Datos\Sites\Projects\rodrigotome.es\node_modules\esbuild\lib\main.js:1650:15)
at E:\Datos\Sites\Projects\rodrigotome.es\node_modules\esbuild\lib\main.js:1059:25
at E:\Datos\Sites\Projects\rodrigotome.es\node_modules\esbuild\lib\main.js:1004:52
at buildResponseToResult (E:\Datos\Sites\Projects\rodrigotome.es\node_modules\esbuild\lib\main.js:1057:7)
at E:\Datos\Sites\Projects\rodrigotome.es\node_modules\esbuild\lib\main.js:1086:16
at responseCallbacks.<computed> (E:\Datos\Sites\Projects\rodrigotome.es\node_modules\esbuild\lib\main.js:703:9)
at handleIncomingPacket (E:\Datos\Sites\Projects\rodrigotome.es\node_modules\esbuild\lib\main.js:763:9)
at Socket.readFromStdout (E:\Datos\Sites\Projects\rodrigotome.es\node_modules\esbuild\lib\main.js:679:7)
at Socket.emit (node:events:514:28)
at addChunk (node:internal/streams/readable:376:12)
It's seem like the package has a lot of code depending of node 🤔
List of dependencies that requiere a node enviroment:
deterministic-object-hash #1 PR- canvaskit-wasm: this package should be compatible with browser https://www.npmjs.com/package/canvaskit-wasm#browser maybe changing some part of the code of this library