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

Add support for Images bindings, with dynamic Sharp import #8008

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ns476
Copy link
Contributor

@ns476 ns476 commented Feb 3, 2025

Previous attempts:
#7424 - Reverted because of a missing permission in E2E tests
#7945 - Reverted because some platforms we support don't have Sharp available

These are both now fixed.

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: In private beta for now, docs are being worked on

ns476 added 3 commits February 3, 2025 11:19
* Add Images binding

* Add Images remote preview mode

* Plumb images local mode flag through

* Add Images binding local mode

* Add Images E2E test

* Hoist @img packages

This fixes the fixture tests, perhaps because sharp does something
unusual with imports, see GH comment: nuxt/image#1210 (comment)

* Add local suffix when printing bindings

* Swap describe/it in E2E test

* Mark sharp as unbundled, rather than hoisting

* Remove zod

* Improve error messages
We want everything that doesn't depend on sharp to work if it is
unavailable, so we need to import it dynamically.
Copy link

changeset-bot bot commented Feb 3, 2025

🦋 Changeset detected

Latest commit: 9b522ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@workers-devprod workers-devprod added the e2e Run e2e tests on a PR label Feb 3, 2025
@ns476 ns476 marked this pull request as ready for review February 3, 2025 13:26
@ns476 ns476 requested review from a team as code owners February 3, 2025 13:26
@lrapoport-cf lrapoport-cf added the caretaking Priority for caretaking label Feb 3, 2025
Copy link
Contributor

github-actions bot commented Feb 3, 2025

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-wrangler-8008

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8008/npm-package-wrangler-8008

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-wrangler-8008 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-workers-bindings-extension-8008 -O ./cloudflare-workers-bindings-extension.0.0.0-v88c7b426e.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v88c7b426e.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-create-cloudflare-8008 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-kv-asset-handler-8008

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-miniflare-8008

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-pages-shared-8008

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-unenv-preset-8008

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-vite-plugin-8008

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-vitest-pool-workers-8008

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-workers-editor-shared-8008

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-workers-shared-8008

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13120191853/npm-package-cloudflare-workflows-shared-8008

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.107.2 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20250129.0
workerd 1.20250129.0 1.20250129.0
workerd --version 1.20250129.0 2025-01-29

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

.changeset/ninety-donuts-warn.md Outdated Show resolved Hide resolved
packages/wrangler/src/dev/miniflare.ts Outdated Show resolved Hide resolved
packages/wrangler/src/images/local.ts Outdated Show resolved Hide resolved
ns476 and others added 2 commits February 3, 2025 18:16
Co-authored-by: Edmund Hung <me@edmund.dev>
@edmundhung
Copy link
Member

I have tested the prerelease version locally with node 16 and I can confirm the issue with sharp is gone:

With prerelease version:

> npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13112532233/npm-package-wrangler-8008 --help               
Need to install the following packages:
  https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13112532233/npm-package-wrangler-8008
Ok to proceed? (y) 
npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
wrangler

COMMANDS
  wrangler docs [search..]        📚 Open Wrangler's command documentation in your browser
  ...

With v3.107.1:

> npx wrangler@3.107.1 --help
Need to install the following packages:
  wrangler@3.107.1
Ok to proceed? (y) 
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'sharp@0.33.5',
npm WARN EBADENGINE   required: { node: '^18.17.0 || ^20.3.0 || >=21.0.0' },
npm WARN EBADENGINE   current: { node: 'v16.20.2', npm: '8.19.4' }
npm WARN EBADENGINE }
npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
npm WARN deprecated wrangler@3.107.1: Please downgrade to v3.106.0
/Users/edmund/.npm/_npx/368e997908476be9/node_modules/sharp/lib/sharp.js:113
  throw new Error(help.join('\n'));
  ^

Error: Could not load the "sharp" module using the darwin-arm64 runtime
Possible solutions:
- Please upgrade Node.js:
    Found 16.20.2
    Requires ^18.17.0 || ^20.3.0 || >=21.0.0
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/Users/edmund/.npm/_npx/368e997908476be9/node_modules/sharp/lib/sharp.js:113:9)
...

@edmundhung edmundhung self-requested a review February 3, 2025 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
caretaking Priority for caretaking e2e Run e2e tests on a PR
Projects
Status: Approved
Development

Successfully merging this pull request may close these issues.

4 participants