-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support browserify #29
Comments
You can add a browser field to package.json that will override local require calls with custom versions. For example {
"browser": {
"canvas": "./canvas.js"
}
} and then in canvas.js: module.exports = function (w, h) {
var elem = document.createElement('canvas');
elem.width = w;
elem.height = h;
return elem;
} |
Thanks. I didn't know about the per-file override. That could refine options 2.i. and 2.ii. |
👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue has already been mentioned in #22, however there still seems to be work to do.
The following three things should be tackled for the original packaging to work together with browserify:
require
-style environment (Support module system for browser environment #28)canvas
dependency.The latter can be solved by the following solutions:
Tell browserify to exclude the canvas dependency. The following is a hacky solution that works for me:
Or in human language: Package imagediff (-e) as a standalone package (-s) by replacing the canvas dependency with our mock (-r) that you shall not include (--exclude).
Use canvas-browserify to always provide a Node.js package, but one that actually works in the browser.
Ask around for other solutions.
I would currently favour 2.ii.
The text was updated successfully, but these errors were encountered: