Experiment to try and get JIMP working with Vite.
Install required system dependencies using ASDF:
asdf install
or manually install them, see ./.tool-versions
.
Install dependencies:
npm ci
Apply jimp patches:
npx patch-package
npm run dev
It's working for loading in a jpeg jimp file with no plugins.
Steps to get this working:
- Use a custom packaging of jimp to strip all features except jpeg parsing. This is just to prove the concept - the idea would be to add back plugins one by one and fix the related issues as they come up. See ./src/custom-jimp.ts.
- Add polyfills for node modules (see
./vite.config.ts
) and./src/node-polyfills.ts
. - Patch jimp packages to use proper ESM. i.e. almost all of JIMP is written in ESM but the code they provide in the package pointed to by
"module"
is not ESM. This is done viapatch-package
. - Change
@jimp/core/src/request.js
to be proper ESM code. In this case it was commonJS file.