piuccio/cowsay

Make web pack compatible.

giodamelio opened this issue · 7 comments

I have been wanting to use cowsay in the web browser for awhile now. There is a fork of this package makes it work, but the docs are not good, and it seems to me that it would be better to make it work on the upstream version.

I was wondering if you would be willing to accept a patch that refactors the loading of the cows to not use any node apis? I was thinking of converting the cow files into json, and writing a build script to convert the original versions to json versions. Should be relatively easy and work seamlessly on both Node.js and in the browser with something like Webpack or Browserify. Creating UMD bundles would also be a possibility.

holy cow! I didn't expect people would use this module in a browser.

Sure it sounds like a good idea, well, as good as using cowsay in node. Let me find some time to think about it. Is it necessary to convert to JSON? Webpack has a plain text loader as well

@giodamelio Do you have time to check the branch browser and see if it works on your setup?

It works great. I didn't know webpack would use the browser field first!

One thing though, the browser.js is not exporting a default which breaks some code.

Adding export default { say, think }; to the end of the file fixes it up just fine.

Thanks so much for doing this, I have to go look into rollup too now, seems pretty nice.

One thing though, the browser.js is not exporting a default which breaks some code.

What code is broken? I wanted to avoid having both a default and named exports

Version 1.2.0 works in the browser