Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's Changing and Why
Core/request is the last source file using commonJS exports. It's not a simple syntax change though since it uses a feature of CJS not available in ESM - conditional exports. Specifically, if in a browser or electron environment then the global
XMLHttpRequest
is being used, but in a node environment the node only packagephin
is being used.This is one of the hard blockers for ESM based tool compatibility (e.g. vite and rollup). See my example repo for a playground trying to get this working.
NodeJS has
fetch
built in from v18 onwards and browser compatibility for fetch is now very high. I propose a move to fetch instead of the conditional requires.I went back and forth about whether to use fetch and rely on the library users to install a polyfill if needed or to include a polyfill within jimp. Without the polyfill I think a lot of projects will break and I think that should maybe be done in a "big" release (like
1.0
), but let me know what you think.What else might be affected
loadFromURL
can take a set ofoptions
. When in the node environment all those options are passed tophin
. Any options used to pass to phin that are not supported by the fetch API will stop working.Tasks
jimp.d.ts
Release Notes
The underlying library for fetching images has been changed.
loadFromURL
can take a set of options. When in the node environment all those options are passed to phin. Any options used to pass tophin
that are not supported by thefetch
API will stop working.