Closed GasimGasimzada closed 4 years ago
Everything in the bin folder is in ES6 module format I'm assuming your react/jest bundling expects it to be in some other format?
Yeah, maybe Jest doesn't use Babel (babel-node
or something similar) to run the app. I will investigate to see if it is possible to do anything about it.
@pshihn one question regarding this. Is it possible to get import rough from 'roughjs';
this one working in a normal webpack + babel based application? Currently, importing like that gives the following error:
TypeError: roughjsWEBPACK_IMPORTED_MODULE13default.a.canvas is not a function. (In 'roughjsWEBPACK_IMPORTED_MODULE13default.a.canvas(_this2.canvas)', 'roughjsWEBPACK_IMPORTED_MODULE13default.a.canvas' is undefined)
Seems like webpack issues.
FWIW, roughjs does ship with a commonjs bundled version. Not sure how you;d include it : roughjs/bundled/rough.cjs.js
It is solved. It can be closed now. Thank you for the help!
My test file only has one line of code:
I am not certain on what the issue is but it seems like it is related to how these packages are bundled.
Also, this error occurs when import anything from the bin directory:
For importing the main rough object, using bundled import fixes the issue:
However, the line above does not work when using webpack (e.g within Create React App).