Skip to content

Conversation

@nicolasiscoding
Copy link
Member

Summary

This PR improves browser compatibility by upgrading xmlbuilder2 and configuring the build to work without requiring Node.js polyfills in Vite and other browser environments.

Changes

  • ✅ Upgrade xmlbuilder2 from 2.1.2 to 3.1.1
    • Fixes browser runtime errors ("Cannot call a class as a function")
    • Fixes "window is not defined" errors in web workers/Cloudflare Workers
  • ✅ Configure Rollup to bundle xmlbuilder2 instead of marking it external
    • Added preferBuiltins: false and browser: true to resolve config
    • Polyfills are now bundled instead of expected as external dependencies
  • ✅ Create browser-compatible image utilities (src/utils/image-browser.js)
    • imageUrlToBase64: Replaces image-to-base64 using browser fetch API
    • getImageSize: Replaces image-size using browser Image API

Still TODO

Related Issues

Testing

  • Builds successfully without warnings
  • Works in Vite without polyfills
  • Works in React without node-polyfill-webpack-plugin
  • Image download and sizing works in browser
  • All existing functionality still works

- Upgrade xmlbuilder2 from 2.1.2 to 3.1.1 (fixes browser runtime errors)
- Configure Rollup to bundle xmlbuilder2 instead of marking it external
- Add preferBuiltins: false and browser: true to Rollup resolve config
- Create browser-compatible image utilities (image-browser.js)
  - imageUrlToBase64: replaces image-to-base64 using fetch API
  - getImageSize: replaces image-size using browser Image API

This addresses browser compatibility issues and removes the need for
Node.js polyfills in Vite and other browser environments.

Related to #97
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.

Readme clarity

2 participants