Skip to content
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

Fabric.js > Canvas dependency breaking (meteor-node-stubs) #7567

Closed
omidahourai opened this issue Aug 3, 2016 · 3 comments
Closed

Fabric.js > Canvas dependency breaking (meteor-node-stubs) #7567

omidahourai opened this issue Aug 3, 2016 · 3 comments

Comments

@omidahourai
Copy link

omidahourai commented Aug 3, 2016

Same issue as #6613 but left unresolved. After installing fabric.js with npm install fabric --save, and import the module on client, I get the error at bootup:

Unable to resolve some modules:

  "../build/Release/canvas" in
/Users/samh/weird-bug/node_modules/canvas/lib/bindings.js (web.browser)

Seems like it's missing "canvas**.node**" in the bindings.js file. Everything worked fine for me with Meteor 1.3-beta8, but upgrading breaks canvas with this error.

I've made a demo of the bug here: https://github.com/ArdentKid/meteor-fabric-bug for anyone to pull and see.

@abernix
Copy link
Contributor

abernix commented Aug 5, 2016

First of all, you should absolutely be using meteor npm install fabric --save and not simply npm install ....

Also, I'm copying relevant comments from #6613 (closed) here:

../build/Release/canvas is meant to refer to a .node binary module, and there's no way to load those modules on the web.browser platform

...indicating that this is occurring because when trying to load a binary in the web.browser bundle – which will not work.

If the canvas package should not be on the client, then it might be advisable for them to make some changes to their package.json to make this more clear to projects like Meteor who have to consume them. While they do specify the engine, they don't specify engineStrict so it merely acts as an advisory – but regardless, engineStrict has been deprecated in NPM 3.0 anyhow. Another (probably better solution) is the browser attribute (which they don't currently set) might solve the problem (though someone would have to test to be sure):

"browser": "./browser.js",

And then browser.js could just be an empty file right next to its package.json.

This probably worked for you in Meteor-1.3-beta8 because you were using a different module? Or maybe an Atmosphere package? Did you change anything during the upgrade?

Haven't had a chance to look at the reproduction but hopefully someone else can.

@omidahourai
Copy link
Author

Exact same implementation, yes using meteor npm install --save fabric see the example for side by side comparison: https://github.com/ArdentKid/meteor-fabric-bug

Meteor 1.4 also requires that I install meteor-node-stubs so I did.

@abernix
Copy link
Contributor

abernix commented Oct 3, 2016

Closing this for the same reason as #6613. You will not be able to load a binary module in the browser and the NPM will need to make considerations on how to deal with that. Last I checked canvas did not do that in a way that can be understood by Meteor. meteor-node-stubs is available to try to solve this, however you can install whatever functions you'd like to mock Node functions and have them behave as you wish. Additional conversation can be found in these issues:

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

No branches or pull requests

2 participants