CamanJS
CamanJS copied to clipboard
Unable to use in webpack
Is it possible to work around camanjs failing on node-canvas when using webpack to bundle it for browser?
My setup: ES6 project with node v6.3.0, babel6, webpack, (OSX).
After installing cairo
, npm install
works:
[email protected] /Users/me/test-caman
└─┬ [email protected]
└── [email protected]
On bundling the source with webpack:
Error in ./~/canvas/lib/bindings.js
Module not found: ../build/Release/canvas in /Users/me/test-caman/node_modules/canvas/lib
@ ./~/canvas/lib/bindings.js 3:17-51
Error in ./~/fibers/fibers.js
Module parse failed: /Users/me/test-caman/node_modules/fibers/fibers.js 'return' outside of function (2:1)
You may need an appropriate loader to handle this file type.
SyntaxError: 'return' outside of function (2:1)
@ ./~/caman/dist/caman.full.js 175:12-29
You can simply set 'export' to undefined and inject the window context with the imports-loader.
import 'imports-loader?exports=>undefined,require=>false,this=>window!caman-dist-only';
It should not work in that way, and also this method will not work with some bootstrap project like create-react-app. So can the environment be detected with more appropriate way?