rough-stuff / rough

Create graphics with a hand-drawn, sketchy, appearance
http://roughjs.com
MIT License
19.83k stars 613 forks source link

Complement documentation for import/require in 4.0 #130

Closed brunok closed 4 years ago

brunok commented 4 years ago

Please complement the documentation for importing/requiring roughjs.

as says in :

the location and names of the bundled resources have changed.

But I didn't find any mention of the correct way to do it in the documentation. People used to node_modules will probably check out that folder and find the correct import, others could be quite lost.

so, for CommonJS: const rough = require( 'roughjs/bundled/rough.cjs.js');

and for ES Modules: import rough from 'roughjs/bundled/rough.esm.js';

Hope this helps

literallysofia commented 4 years ago

This saved me a lot of time! Thanks!

pshihn commented 4 years ago

Thanks. Based on the project.json file. It should automatically be picked up now:

 "main": "bundled/rough.cjs.js",
  "module": "bin/rough.js",
  "types": "bin/rough.d.ts",
  "browser": "bundled/rough.js",
pshihn commented 4 years ago

Also updated the docs. Thanks for reporting