Skip to content

feat: support sharp as alternative SVG→PNG converter for satori#494

Draft
harlan-zw wants to merge 1 commit intomainfrom
feat/sharp-svg-to-png
Draft

feat: support sharp as alternative SVG→PNG converter for satori#494
harlan-zw wants to merge 1 commit intomainfrom
feat/sharp-svg-to-png

Conversation

@harlan-zw
Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Related to #435

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Migrates SVG→PNG conversion from @resvg/resvg-js to @napi-rs/image and adds sharp as an alternative SVG→PNG backend for satori on node runtimes. When both are available, sharp is preferred; if neither is installed, the module errors with guidance to install @napi-rs/image.

Includes sharp-node and sharp-node-dev worker-threaded bindings, alternatives support in dependency detection, and updated compatibility schemas. WASM runtimes (Cloudflare, Vercel Edge) continue using @napi-rs/image as sharp has no WASM build.

🚧 Status

Draft — incomplete. The sharp preference logic in module.ts and the unified image-transform binding (to consolidate SVG→PNG, SVG→JPEG, SVG→WebP into one abstraction backed by either sharp or @napi-rs/image) are not yet wired up. The @napi-rs/image WASM bundle is ~9.2MB vs @resvg/resvg-wasm at ~2.5MB — may revisit WASM strategy before merging.

- Migrate from @resvg/resvg-js to @napi-rs/image for SVG→PNG conversion
- Add sharp-node and sharp-node-dev bindings as alternative SVG→PNG implementations
- Add `alternatives` field to ProviderDependency for either/or dependency detection
- Rename resvg binding to svgToPng across compatibility schemas
- Add netlify-satori test fixture and e2e tests
- Docs and migration guide updates for v6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant