robbestad/Rantjs

any plans for node?

Closed this issue · 4 comments

This project looks great!

Any plans for node support? Using modules (ES6 / CommonJS) would probably clean up your build step quite a lot as well.

Hmm... I'm definitely considering making it more modular. I've relied on prototypal inheritance because my original aim was to use the end product in ImpactJS, and there's no easy way to use CommonJS or require in that framework (it's got its own module system).

But.. I love node, so I made it so that rantjs is exportable and there's a version on npm right now: https://www.npmjs.com/package/rantjs. If you got any specific tips on how to make it more node-friendly, I'm more than happy to oblige. :)

You could author your library in CommonJS, and then bundle it with browserify into something that ImpactJS supports. We've done the same on CocoonJS projects, and even in Adobe ExtendScript, so I don't see why it wouldn't work in ImpactJS.

This is also a good approach for general browser dev. You can use tape or prova for unit testing in both node and the browser.

This means anyone consuming the module (with Browserify, Webpack, or NodeJS) would consume your "raw" source. You could provide a downloadable UMD build for other formats (like ImpactJS, AMD, or <script> tag).

And because you're using modules, you could also take advantage of things on the npm ecosystem. They may or may not be what you need: to-title-case, lex, etc.

While on the subject of refactor, you might want to consider a simpler end-user API, like exporting the common use case as a default method. The current setup is cumbersome IMHO.

var sentence = require('rantjs')('.. pattern here ...')

Thanks for your comments. This is very helpful. Your example at the end makes it clear how rantjs could be easier to use and I like the idea. I'll put new features on hold and implement this before moving on 👍

Done