jimp: Browser version requires missing files.
Expected Behavior
Using the browser version of JIMP, e.g. when running Browserify on a Node.JS package that requires JIMP, should be clean, as it should contain all of the JIMP code in a single file.
Current Behavior
Browserify (most likely the browser too, if you use the browser version directly in the browser) will error due to erroneous calls to require().
Failure Information (for bugs)
The error complains about ./src/converter, which simply doesn’t exist in jimp/browser (where jimp is the node_modules subfolder where jimp is installed, when installed from npm).
Steps to Reproduce
I haven’t tried to use JIMP directly in the browser, but here’s how to reproduce this error the way I noticed it.
- Create a simple Node.JS project.
- Install JIMP as a dependency (
npm i --save jimp). - Create an
index.jsfile with the following contents:
const JIMP = require('jimp');
- Run
browserify index.js.
Context
- Jimp Version: JIMP 0.6.0.
- Operating System: Linux Mint 19 “Tara” (Ubuntu fork), kernel Linux v4.20.
- Node version: Node.JS v8.10.0.
Failure Logs
> nodemips@0.1.1 build /home/gustavo6046/Source code/nodemips
> browserify -r ./index.js:mips | babel --minified -f minif.tmp | uglifyjs >browser/mips.js
Error: Cannot find module './src/converter' from '/home/gustavo6046/Source code/nodemips/node_modules/jimp/browser/lib'
at /home/gustavo6046/Source code/nodemips/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
at load (/home/gustavo6046/Source code/nodemips/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
at onex (/home/gustavo6046/Source code/nodemips/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
at /home/gustavo6046/Source code/nodemips/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:152:21)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (9 by maintainers)
I can do it if you want me to. It’ll be quick and simple enough.
Either way, maybe it would be a good idea to assign someone to do the job, to avoid concurrent pull requests trying to do the same thing.
I’m pretty sure it would be better to leave it to the user, unless JIMP relies on features that don’t work in the browser.