rough
rough copied to clipboard
Failed to Minify the Code
When trying to update Semiotic to use a version of Rough that was not my own ES5 tenderized version I get the following error: Failed to minify the code from this file: ./node_modules/roughjs/dist/rough.umd.js:1:220
Are there certain settings for babel and rollup necessary to build Rough in a project?
If rest of your code is ES6 then you can just import unbundled rough.js in your code and let your own build script deal with appropriate transpilations.
But, i also ship with an es5 bundled version now:
.../dist/rough.es5.umd.js
This is not the default module but you can try pointing your code to this file if you want to use the ES5 build
@emeeks I am not sure if you ever solved this issue. I am not an expert in webpack, but from what I recall semiotic needed an es5 build - which roughjs now ships with /dist/rough.es5.umd.js
@pshihn I just installed the latest version of rough @4.0.4 and I am receiving this error when trying to build with rough in my library. I am building a project which passes roughjs into Semiotic, so thought it was relevant to the above thread.
`Creating an optimized production build... Failed to compile.
Failed to minify the code from this file:
./node_modules/roughjs/bundled/rough.esm.js:1:71
` I have not tested the es5 version you discuss above because I only see rough.esm.js in the bundle within node_modules.
@demartsc Not sure what the setup is. I suspect it's Webpack and I have no experience in it. I can tell you that roughjs ships with following 3 bundled versions:
CommonJS: roughjs/bundled/rough.cjs.js ESM: roughjs/bundled/rough.esm.js Browser IIFE: roughjs/bundled/rough.js
When importing roughjs try the commonJS location.
Also look at setup of https://github.com/excalidraw/excalidraw - also a react app that includes and builds roughjs
I had the same issue with the cjs build. Seems to be a problem with minifying already minified code.
I worked around this issue by creating my own unminified build using rollup.
rollup --format cjs -i node_modules/roughjs/bin/svg.js -o client/utils/rough.js -p node-resolve
Now you can use the build like so
const RoughSVG = require('/client/utils/rough').RoughSVG
const rough = new RoughSVG(domMock)
I added this to my postinstall task in package.json and ignored the resulting file in .gitignore
Another advantage of this is, that I now only have an svg-only-build, because I don't use the canvas one.
I advice to not minify by default but provide a minified version which really only makes sense for the Browser-IIFE build. For all other versions the consumer should take care of this.