justin-schroeder / arrow-js

Reactivity without the framework
https://arrow-js.com
MIT License
2.38k stars 49 forks source link

Add support for emitting IIFE #65

Closed vascanera closed 1 year ago

vascanera commented 1 year ago

This PR adds support for emitting IIFEs to be used in legacy mode. The emitted files are dist/index.js, dist/index.min.js and their corresponding .map files. The functions are exported under a global variable $arrow, thus, the usage would be: $arrow.r(...); $arrow.w(...); $arrow.t(...)

It would be nice to have individual variables exported for each function, like $r(...); $w(...); $t(...) - this would be awesome, actually.

Cheers! Keep up the good work!

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
arrow-js ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 22, 2023 at 9:02PM (UTC)
justin-schroeder commented 1 year ago

Thanks! If you want to work out the $r, $w, $t portion of this I'd be thrilled, it should be doable via rollup exclusively I think.

vascanera commented 1 year ago

Will write some minimal documentation for this addition (how to use in IIFE mode) these days.

vascanera commented 1 year ago

Thanks! If you want to work out the $r, $w, $t portion of this I'd be thrilled, it should be doable via rollup exclusively I think.

Actually, on second thought, I don't know if this is a good idea. Exposing just $arrow as a global variable (that has .r(), .w() and .t() as members) is more future proof. If you end up adding more methods to the library, all these new methods should be reflected as global variables using the same naming convention - it might get messy. It is up to the developers using the library to do as they please and further expose internal structure - IIFEs are more of an exception nowadays, so this should be fine as it is. Cheers!