-
Notifications
You must be signed in to change notification settings - Fork 57
After update to 0.1.2 version getting error #11
Comments
Same here, here's the offending line in canvas.js :
|
OK, I will push a 0.1.3 that fixes this soon. |
I just published 0.1.3, let me know if that fixes the issue. |
BTW, what platform was this occurring on? |
You can't have conditional requires in tools like babel because everything is compiled into the bundle that is pushed to browsers. I think your best best is to make two end point versions of this module, one for node canvas and one for everything else. Alternatively you could have a static function that you pass in the prototype to extend. I use Node Canvas in my work and personally I vote on not supporting it as a first class citizen. It's api doesn't follow the standards. To get around this and the other issues with older canvas implementations in my projects I write adapters in front of the CanvasRenderingContext2D to get around the inconsistencies between Node Canvas and the browsers. If you implement the method where a prototype can be passed in I can just pass in my adapter, but for everyone else having two api end points is likely going to be the simplest. |
I'm running macOS Sierra 10.12.4 and I was using canvas-5-polyfill with Node Canvas. |
I am using windows 7 Professional, node, ES6 and bable |
@talltyler "I think your best best is to make two end point versions of this module, one for node canvas and one for everything else." That does sound like a good fix, could you submit that as a pull request? |
I've looked into doing this and I'm not sure I'm the person to do this. It looks to me as though this repo should be broken up into a few parts. First supporting the feature and then a different module for making that work within Node Canvas. I would also be tempted to rename this project Path2D-polyfill or something like that. |
Simply adding a "browser": {
"canvas": false
} Doing so will see Browserify and Webpack ignore the For more information, see here. Actually, that's not the only problem. Declaring var CanvasRenderingContext2D = CanvasRenderingContext2D; Ensures that it will always be |
Sorry for the delay, I just published the 0.1.5 release which includes this fix. |
Using webpack and trying to import this file gives me the same "Can't resolve 'canvas'" error. (I'm using v0.1.5) |
@diegodoumecq It seems that Webpack performs some static analysis and is able to determine that If something else - e.g. |
I'm new to webpack, but found myself here.... I was able to get webpack happy for my own dependency on canvas-5-polyfill using the addition of: To prevent the require from failing. |
Up, the same problem ERROR in ../node_modules/canvas-5-polyfill/canvas.js
Module not found: Error: Can't resolve 'canvas' in '/web/node_modules/canvas-5-polyfill'
@ ../node_modules/canvas-5-polyfill/canvas.js 16:29-50 |
I am getting error after updating to newer version,
ERROR in ./
/canvas-5-polyfill/canvas.js/canvas-5-polyfill/canvas.js 14:29-46Module not found: Error: Can't resolve 'canvas' in 'D:\src\node_modules\canvas-5-polyfill'
@ ./
The text was updated successfully, but these errors were encountered: