-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Get rid of node-canvas dependency #5735
Comments
If you install with NPM and you use for the browser, you likely use a bundler. Here is an example for webpack. node-canvas 2 should install plain simple since is prebuilt for most systems. I cannot get rid of the 2 dependencies or i would leave a package in npm that does not work by default and i do not like this idea. I will close the issue as i did for similar bundling/installing issues, but i m very open to continue talking of your specific problem, we could both learn something. |
@asturur I use webpack but it doesn't actually matter here. The issue happens on
I'm also thinking in case if you reject my proposal to create the alternative package by myself which is going to run a script before install which will pull this repository, modify package.json and install fabric.js without these dependencies. But I will loose versioning then... |
In our project, we are using webpack, react and serverside rendering, and after we had upgraded fabric to 3.1, we started to get problems with node-canvas. After deploying to the server, on server rendering we started to get the error 'Cannot find module '../build/Release/canvas.node' at module.js'. The strange thing is that there is no code connected with node-canvas in the bundled file. Another strange one is that the error disappears after several reloads of the page. After deploying, js file is being bundled only once, and after reloading the page it could not be changed, but suddenly the error had gone, and I cannot get why. Tried to use webpack config with configuring externals, that was mentioned earlier and it does not help. Helps only downgrading to 2.7 as it uses an earlier version of node-canvas. My guess is that in node-canvas has changed the way of installing in version 2.0. But why it is trying to be installed if it is optional dependency and was not required anywhere, still to be a question? |
Optional dependency means that if it fails installing there are no problems. Can you post more of your webpack error? |
@finom i have a window machine here now, can you help me replicate a configuration where node-canvas is breaking an npm install? |
@asturur Hello, I am speaking on behalf of AmCharts. We provide a browser-only charting library for our customers. Therefore we do not need We would really like to use Fabric, since it is a wonderful library, but we cannot do so, because of the required dependency on We are aware that
When any of the above situations happen, the customer gets a huge and scary error message:
Even though installation may technically have succeeded, our customers panic because it certainly looks like there is something wrong. After getting this message, they contact our customer service. It is quite frustrating for both us and our customers that we have to inform them that we cannot fix the issue (because the issue is with And requiring our customers to go through the installation guides is not acceptable. They pay us money and they expect a very simple works-out-of-the-box experience. For similar reasons, we cannot tell them to just ignore the error. The canvg library solved this issue by making |
Hi @Pauan , thanks for your interest in fabricjs first of all. We should first consider that removing a dep is a breaking change, so i should wait for a 4.0 release anyway. Then there is something I' m not really happy about, the tradeoff. Node developers on the other hand from that day on, have to add node-canvas manually. Making a change to the installation process to favor some devs over others, just because the former do not want to take their time to understand a log, to me feels like the defeat of the whole purpose of this repository that for me has always been learning. I have also asked myself why there are no options in npm to suppress log per packages or to specify a browser/node installation mode, everything brings to the point of having a different package or to favor a kind of user over another. now .npmrc has an option called loglevel that can be set to silent, I wonder if that is used when the package is used as a dependency or not. We can try that, the alternative then is to make a script that removes the dependency from the package.json and to run that script each release to publish a different package. This would flatter me anyway. I have a question tho. armchart is not yet using fabricjs, so i would like to know if this:
is a projection of a possible future, or is a test run with an armchart version that supports fabric. |
Yup, I know. But if I didn't bring up the problems now, then the change would never happen.
Our customers have a wide range of abilities. A few of them are quite experienced, but many of them are very inexperienced, which is why they pay us for customer service. Yes, some of them do get scared by logs, and no, adding more documentation does not help. We have extensive documentation (including for installation), but it does not help, especially because many of our customers do not read the documentation in the first place. Even for very simple things (which are covered in the documentation), we have to repeatedly answer the same questions over and over again. It's not possible to force people to learn. I know this can be hard to believe (especially if you're an experienced developer), but it is the reality of our business.
Node users merely have to run
Right now the installation process favors Node users, because browser users must always pay the cost of downloading
I agree that the fault ultimately lies with npm and their lack of truly optional dependencies (or compilation targets), but since they lack such things, it's up to us to figure out workarounds. We don't have the luxury of waiting years for npm to create such a system (if they ever do).
We used Fabric in the past, but because of the issues we had with our customers, we switched to canvg. But since Fabric is much more feature-filled than canvg we would really like to switch back to Fabric. |
Guys, I've created a package for these needs: https://www.npmjs.com/package/fabric-pure-browser @asturur I've got one idea: why not to publish a browser-only fabricjs version with a "-browser" postfix as I did for "fabric-pure-browser" package? |
would be nice to keep it in the main fabricjs org. |
The script temporarily overrides package.json contents with `optionalDependencies: {}` and `version: 'FABRIC_VERSION-browser'`, publishes it, restores the original package.json and publishes the main version. It can be run with `node publish` and it also supports original `npm publish` parameters: `node publish --dry-run`. The file is eslinted with .eslintrc.json. Closes #5735.
The script temporarily overrides package.json contents with `optionalDependencies: {}` and `version: 'FABRIC_VERSION-browser'`, publishes it, restores the original package.json and publishes the main version. It can be run with `node publish` and it also supports original `npm publish` parameters: `node publish --dry-run`. The file is eslinted with .eslintrc.json. Closes fabricjs#5735.
Hi, I see that "fabric" now has versions postfixed -browser. I don't think this solves the problem, as yarn add fabric:3.6.3-browser still comes with canvas as an optional dependency. In the mean time, I'm going to use finom's fabric-pure-browser |
mmm very strange, it should not have the the dependency listed. |
@finom As someone who is currently diagnosing a broken build, 5:30PM on a Friday, thank you for |
For anyone to use Typescript typings from
/// <reference types="fabric" />
declare module 'fabric-pure-browser' {
export * from 'fabric';
}
{
...
"compilerOptions": {
...,
"typeRoots": ["./typings", "./node_modules/@types"]
}
} |
consider fabric exists with a browser counterpart in the main repo and has the -browser suffix on the version. |
Hey All, I need to set limit on caches when rendering heavy SVGs and I am using,
The issue i have is, the properties I am getting the error
and I am unable to set the properties. I am using
Please assist me in setting the values. |
Some team members get lots of troubles while they install fabricjs because of the issues of installing node-canvas. I also got some troubles but I'm happy to be an macos user and it wasn't hard to fix it. Windows users aren't so happy with that :D
We use fabricjs only for browser-side development and we don't need any features for nodejs. Is that possible to remove "canvas" from "optionalDependencies", add it to "devDependencies" and leave a note at README that if somebody wants to use node-canvas then he/she needs to install it manually?
A good bonus would be also to get rid of "jsdom" dependency because it just gives a package more weight.
The text was updated successfully, but these errors were encountered: