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

@astrojs/image works locally but not on Netlify Edge #5307

Closed
1 task
toddmorey opened this issue Nov 6, 2022 · 4 comments · Fixed by #5317
Closed
1 task

@astrojs/image works locally but not on Netlify Edge #5307

toddmorey opened this issue Nov 6, 2022 · 4 comments · Fixed by #5317
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: image Related to the `@astrojs/image` package (scope)

Comments

@toddmorey
Copy link

What version of astro are you using?

1.6.0

Are you using an SSR adapter? If so, which one?

astrojs/netlify 1.2.0 (targeting edge functions)

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

Similar issue to #5253. Astro projects that include astro/image seem to fail on deploy, at least when targeting Netlify Edge Functions.

Right after building server entrypoints, it errors out with Cannot bundle Node.js built-in "node:fs/promises" imported from "node_modules/@astrojs/image/dist/utils/metadata.js". Consider disabling ssr.noExternal or remove the built-in dependency.

Here are the build logs from Netlify:

11:40:27 PM: $ astro build
11:40:28 PM: 04:40:28 AM [build] output target: server
11:40:28 PM: 04:40:28 AM [build] deploy adapter: @astrojs/netlify/edge-functions
11:40:28 PM: 04:40:28 AM [build] Collecting build info...
11:40:28 PM: 04:40:28 AM [build] Completed in 36ms.
11:40:28 PM: 04:40:28 AM [build] Building server entrypoints...
11:40:29 PM: [commonjs--resolver] Cannot bundle Node.js built-in "node:fs/promises" imported from "node_modules/@astrojs/image/dist/utils/metadata.js". Consider disabling ssr.noExternal or remove the built-in dependency.
11:40:29 PM:  error   Cannot bundle Node.js built-in "node:fs/promises" imported from "node_modules/@astrojs/image/dist/utils/metadata.js". Consider disabling ssr.noExternal or remove the built-in dependency.
11:40:29 PM:   File:
11:40:29 PM:     Error
11:40:29 PM:   Stacktrace:
11:40:29 PM: Error: Cannot bundle Node.js built-in "node:fs/promises" imported from "node_modules/@astrojs/image/dist/utils/metadata.js". Consider disabling ssr.noExternal or remove the built-in dependency.
11:40:29 PM:     at error (file:///opt/build/repo/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
11:40:29 PM:     at throwPluginError (file:///opt/build/repo/node_modules/rollup/dist/es/shared/rollup.js:21587:12)
11:40:29 PM:     at Object.error (file:///opt/build/repo/node_modules/rollup/dist/es/shared/rollup.js:22541:20)
11:40:29 PM:     at Object.resolveId (file:///opt/build/repo/node_modules/vite/dist/node/chunks/dep-c842e491.js:34805:34)
11:40:29 PM:     at Object.handler (file:///opt/build/repo/node_modules/vite/dist/node/chunks/dep-c842e491.js:46785:19)
11:40:29 PM:     at file:///opt/build/repo/node_modules/rollup/dist/es/shared/rollup.js:22748:40
11:40:30 PM: ​
11:40:30 PM: ────────────────────────────────────────────────────────────────
11:40:30 PM:   "build.command" failed                                        
11:40:30 PM: ────────────────────────────────────────────────────────────────

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-6xnc83?on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.
@delucis
Copy link
Member

delucis commented Nov 6, 2022

I believe this is a known limitation due to reliance on Node.js APIs. The integration docs say:

Note that @astrojs/image is not currently supported on

  • Cloudflare SSR
  • @astrojs/deno
  • @astrojs/netlify/edge-functions
  • @astrojs/vercel/edge

@matthewp
Copy link
Contributor

matthewp commented Nov 7, 2022

We should add an explicit error message when trying to use with known, non-supported adapters.

@matthewp matthewp self-assigned this Nov 7, 2022
@matthewp matthewp added pkg: image Related to the `@astrojs/image` package (scope) - P3: minor bug An edge case that only affects very specific usage (priority) labels Nov 7, 2022
@toddmorey
Copy link
Author

I definitely saw the note in the docs, though the explicit error message would help, too. I submitted this as a bug after talking to @FredKSchott who thought it may be working in Deno environments and the docs just may be out of date. Totally understand that adding Deno support for image processing like this is no small task.

@matthewp
Copy link
Contributor

matthewp commented Nov 8, 2022

@toddmorey there's a fix for this in #5317. @astrojs/image does not work in any non-Node environments at the moment, however. #5317 will error when trying to use a non-supported adapter.

#4109 is going to be the attempt to make it work in Deno (and other non-Node runtimes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: image Related to the `@astrojs/image` package (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants