nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
983 stars 56 forks source link

Image Processing #270

Closed fabianwohlfart closed 2 months ago

fabianwohlfart commented 2 months ago

Describe the bug It's not possible to use several image processing libraries. I tried: sharp, @cf-wasm/photon, image-js.

[error] Cannot resolve "@img/sharp-wasm32/versions" from "/opt/buildhome/repo/node_modules/sharp/lib/utility.js" and externals are not allowed!
12:06:45.291   at Object.resolveId (node_modules/nitropack/dist/nitro.mjs:1970:17)
12:06:45.291   at async PluginDriver.hookFirstAndGetPlugin (node_modules/rollup/dist/es/shared/node-entry.js:19818:28)
12:06:45.291   at async resolveId (node_modules/rollup/dist/es/shared/node-entry.js:18509:26)
12:06:45.291   at async ModuleLoader.resolveId (node_modules/rollup/dist/es/shared/node-entry.js:18912:15)
12:06:45.291   at async node_modules/@rollup/plugin-commonjs/dist/es/index.js:785:16
12:06:45.291   at async Promise.all (index 5)
12:06:45.291   at async node_modules/@rollup/plugin-commonjs/dist/es/index.js:777:32
12:06:45.292   at async rewriteRequireExpressionsAndGetImportBlock (node_modules/@rollup/plugin-commonjs/dist/es/index.js:1354:28)
12:06:45.292   at async transformCommonjs (node_modules/@rollup/plugin-commonjs/dist/es/index.js:1933:23)
12:06:45.292   at async transform (node_modules/rollup/dist/es/shared/node-entry.js:18830:16) 

Steps to reproduce Steps to reproduce the behavior: npm install sharp

Expected behavior The only library i could get to work is jimp. If I understand correctly its a cloudflare thing not to allow externals. Unfortunately I do not even know what is meant by this and there is no documentation for it. Would be great to have a short example on how to do basic image processing like resizing in NuxtHub. I wonder if this also breaks NuxtImage as this also relies on sharp?

atinux commented 2 months ago

Duplicate of #131

Please feel free to comment on it as I would like to explore @cf-wasm/photon