TomFrost / Jexl

Javascript Expression Language: Powerful context-based expression parser and evaluator
MIT License
573 stars 93 forks source link

Ready to use frontend script #50

Closed Loceka closed 5 years ago

Loceka commented 5 years ago

In the original project, there was a "ready to use" frontend script, in the form of a minified js file :

For the frontend, drop dist/jexl.min.js into your project and include it on your page with: <script src="path/to/jexl.min.js"></script>

I would be a really appreciated gesture, since not everyone uses node.js (or even likes it) and since it is pretty heavy to install/configure, even more since the "trendy tools" change every month or so...

Would it be possible for you to generate a "standalone" javascript file (minified or not) to be used in a frontend only context?

TomFrost commented 5 years ago

Hi Loceka!

I removed the dist file in the 2.0 release for a few different reasons:

I'd strongly recommend looking into a bundler for your project, as it really is the best way to go in most cases. We use Parcel at my company and love it -- there's no config file to worry about and it makes all the right choices. If you require a dist file and can't build it yourself, the last one made available is for version 1.1.4 here: https://github.com/TomFrost/Jexl/tree/1.1.4/dist

That tag also includes the gulpfile that I used to package that version, so you’re welcome to try running the same process on top of the latest release. ...but really, I can’t stress enough, taking the hour to learn how to run parcel on top of your project will open up a world of options in terms of available dependencies. I can’t recommend it enough.

Best of luck!

Loceka commented 5 years ago

Thank you for the detailed comment!

I currently use the 1.1.4 (from the original project but I assume there is no difference between the 2) but I was really interested in your "evalSync" addition. Had no problem at all regarding it's integration really, since it generates only one variable (called required) that you can wrap however you want, or rename if you fancy.

I've had to use node.js a couple of time (or a bit more) and every time it's been a really painful experience and I'm not looking forward to trying it again ^^

But I'll follow your lead and try making Parcel work. I understand trying to satisfy everyone's need by providing a bundled package can be cumbersome and you don't want to bother with that.

Thanks again, Loceka.

jarrodek commented 5 years ago

What about ES6 modules then? To give you a use case. Assume you are building your apps from web components. Some portions of the app uses Jexl (in different components). Currently to avoid Jexl being bundled/included into the app multiple times you would have to fork and maintain own repo with ES6 bundle. The same would be to use the library naively in web components. WC use npm to install dependencies but there's no way to include this library into WC without transpilation or other transformation. It makes it quite difficult to maintain. I did exactly this before with Jexl when HTML imports was a thing to manage WC dependencies. Now I wanted to use original repo instead having a fork. It turns out it is not possible without having ES6 modules version. There are npm modules that automatically build ES6 ready version of the module at publish time.