eta-dev / eta

Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
https://eta.js.org
MIT License
1.35k stars 60 forks source link

Is it possible to use eta.js in minified state? #287

Closed serge-starynets closed 1 month ago

serge-starynets commented 1 month ago

Hello,

Is it possible to minify eta.js code and use it? As example, I have some js evaluator tool which accepts js code as string and runs it. For now it is possible to integrate minified version of another template library - I just add minified library code to the user provided code before run. So can I do the same with eta.js?

Thanks!

nebrelbug commented 1 month ago

I'm not quite sure what you're trying to do. Eta is already released as a minified bundle.

serge-starynets commented 1 month ago

So basically I want eta.js be available inside isolated-vm library runtime. I'm concatenating minified eta.js code with some JS code and pass it to the isolated-vm eval function. This approach worked well with another templating library, but eta.js is more powerful and I'm wondering if it's even possible.

So far I'm getting Eta is not defined error when try to run code with described approach.

I know that eta.js minified bundle works in browser's environment, but maybe it's not the case for Nodejs?

nebrelbug commented 1 month ago

@serge-starynets are you using dist/eta.umd.js?

serge-starynets commented 1 month ago

@nebrelbug Yes but I minified it and I think that's was the issue. I tried without minification and the error gone now. Thanks for the hint!

nebrelbug commented 1 month ago

@serge-starynets glad that the issue was resolved!