google / closure-templates

A client- and server-side templating system that helps you dynamically build reusable HTML and UI elements
Apache License 2.0
639 stars 194 forks source link

Missing soyutils.js in this GitHub Repository #129

Open craph opened 7 years ago

craph commented 7 years ago

Hi,

I was looking for all examples for the usage of closure library with Javascript and I think a file is missing in this repository.

This file is : soyutils.js It's required when you don't have closure library

Please could you have a look and fix this ?

More over, the links in the README.md about latest Javascript compiler point to an out of date version. Please could you update this one.

I have double check the pom.xml but there are no indication to generate the soyutils.js. Could you give us the process ?

Thanks in advance for your help 👍

craph commented 7 years ago

After some investigation in the history of this GitHub repo, I think the reason why soyutils.js is missing is because of these two commits :

  1. Deprecate soyutils.js and recommend the _usegoog version.

  2. Remove the non-Closure version of Soyutils.

But could you explain and update the documentation on how to use the _usegoog version and which files of closure library should we includes in project to have all working nicely ?

What can we have to download on closuse-library repo and which files must be provide to have soyutils_usegoog.js to work perfectly ?

More over, could you update all javascript example in this repo because all of these files use the wrong one and no one can understand the best way to use soyutils_usegoog.js

Many thanks.

Womps commented 7 years ago

Hi !

In my team, we're trying to use this Framework in JavaScript too.

We have the same problem, following the documentation and examples on the github repository.

The file soyutils.js is linked, but this file is missing and we don't find it...

So, what we also ask is how to use soyutils_usegoog.js version ?

Thanks

eduardolundgren commented 7 years ago

We had the same problem when soyutils.js was removed. We ended up maintaining our own manual version for simplicity and bundle size optimizations.

craph commented 7 years ago

Thank for your reply @eduardolundgren

But if I read correctly the links mentionned in my previous comment, the best way is to use Closure Library. That's why I asked the Google Team to know what is the best way to use soyutils_usegoog.js in those examples and which files/version of Closure Library we must use.

And finally if the documentation on the developers site can be updated and the examples in this GitHub repo too.

eduardolundgren commented 7 years ago

@craph sure, that would be ideal from them to provide that information.

In the past we've figured out how to generate their bundle, the reason we ended up not using Google's version was file-size, it was around 40% bigger (IIRC) of the what we manually generated.

craph commented 7 years ago

@mikesamuel , @lukesandberg ,

Please could you give us some informations about that, update examples and explains how to use the soyutils_usegoog.js with closure library ?

mikesamuel commented 7 years ago

Will do.

craph commented 7 years ago

@mikesamuel , when this will be possible to know what is the right way to use the use_goog.js version through examples in the Github repo and documentation ?

In advance, many thanks.

craph commented 7 years ago

@mikesamuel : Any news about this ? Many thanks.

craph commented 7 years ago

@mikesamuel : Do you have any news about this ?

Many thanks.

mikesamuel commented 7 years ago

I started pulling threads. I can easily generate a single JS bundle containing soyutils_usegoog.js, soydata_converters.js, and all their dependencies.

soy_runtime_onefile.js.gz

This works, but weighs in at slightly < 1MB because it pulls in a bunch of closure library files that it only needs one function from.

Do you plan on using JSCompiler or another JS minifier with this?


Doing it properly -- eliminating all the closure library dependencies -- will require enumerating all the symbols that the JS compiler generates so that I can point closure compiler at a list of goog.exportSymbol calls for everything actually needed by compiled soy templates.

I can do that, but it will take some time to get through review.

craph commented 7 years ago

@mikesamuel , Thank you for the JS bundle. But I am not planning to use JSCompiler or other JS minifier.

So ...

I will be very happy if I could use the _usegoog.js file in JavaScript.

After some investigation in the history of this GitHub repo, I think the reason why soyutils.js is missing is because of these two commits :

  1. Deprecate soyutils.js and recommend the _usegoog version.

  2. Remove the non-Closure version of Soyutils.

If I understand good to use closure template in JavaScript we must use soyutils_usegoog.js.

Please could you explain and update the documentation on how to use the soyutils_usegoog.js version and what can we have to download on closuse-library repo and which files must be provide to have soyutils_usegoog.js to work perfectly ?

More over, could you update all javascript example in this repo because all of these files use the wrong one and no one can understand the best way to use soyutils_usegoog.js

Many thanks @mikesamuel.

mikesamuel commented 7 years ago

Ok. So it sounds like a JS bundle that includes all the goog. dependencies required by soy. namespace and the goog.* requires generated by SoyToJsCompiler would meet your needs. Is that about right?

If so, I think I can do that.

craph commented 7 years ago

Yes I think it's that BUT

In fact as mentionned in #127 In soyutils.js I cannot find this function : soy.asserts.assertType(...)

And as you can see this two links related to older commit in this Github repo :

  1. Deprecate soyutils.js and recommend the _usegoog version.

  2. Remove the non-Closure version of Soyutils.

soyutils.js mustn't be used anymore.

That's why I requested an update of examples in this repo that are pointing to the wrong version and I requested an update of the official documentation in the developpers site.

As you can see those two commits, it's mention that it is better to use the soyutils_usegoog.js file.

BUT with soyutils_usegoog.js we must use closure-library but it's not documented anywhere ... We don't know which files are required ....

So for all developpers and all users I think it better to update all examples in the Github repo and explain the right way to use it in Javascript with soyutils_usegoog.js because I am not alone in this case.

All example here are wrong and the documentation here too : Closure Template developers site

Many thanks @mikesamuel

mikesamuel commented 7 years ago

In fact as mentionned in #127 In soyutils.js I cannot find this function : soy.asserts.assertType(...)

Yes, soyutils.js no longer exists.

There used to be 2 JS files that we provided soyutils_usegoog.js and soyutils.js which was soyutils_usegoog.js with just enough closure to work.

We stopped providing that, and we do need to update documentation.

Even if you were to copy soy.asserts into the latest version of soyutils.js you would probably run into a similar missing or outdated API problem.

So we're not going to provide update the old soyutils.js, but instead I can provide just enough closure so that you can load

and then we can start updating documentation to explain how to

  1. explain how to use the soy JS runtime with closure
  2. explain why it's a really good idea to use closure compiler with soy-generated JS.
  3. explain how to use it without closure compiler
  4. reiterate 2.
eduardolundgren commented 7 years ago

@mikesamuel Yes, that would be a huge help. If possible to provide those files eliminating all the closure library dependencies or at least enumerating all the symbols that the JS compiler generates would help the community maintain an optimized version. Thanks a lot!

mikesamuel commented 7 years ago

I've done some internal plumbing so that we can maintain such a list of exports and provide a single JS file with all the closure stuff needed that still allows JSCompiler to eliminate most of the dead code, along with some testing trickiness so this doesn't turn into a maintenance headache.

I still need to figure out how to run our end-to-end tests with this as the JS runtime library. I should have a sense of how that's going soon.

craph commented 7 years ago

@mikesamuel It would be a pleasure to use closure-template in Javascript in the right way. 👍

So if it will be possible to update the documentation and examples in this Github repo on how to use the soyutils_usegoog.js file and provide those files it would be a huge help for the community 👍

I am waiting for that.

Thank you very much!

tntim96 commented 7 years ago

Agree with the comment above.

The file soyutils_usegoog.js isn't a drop-in replacement for soyutils.js and is missing at least var goog = goog || {};, so documentation and examples on how this works would be great.

I've found soy_usegoog_lib.js does seem to replace soyutils.js as it has the code that's missing from soyutils_usegoog.js, however that comes from the test directory and isn't the documented replacement.

craph commented 7 years ago

@mikesamuel , any news about this subject ?

My team and I are waiting for that.

Thank you very much!

craph commented 7 years ago

Hi @mikesamuel , @lukesandberg

My Team and I are waiting for an explanation on how to use the soyutils_usegoog.js and our project is still in standby because of that.

So please could you have a look and tell us the correct way.

In advance, many thanks for your help.

Best regards

craph commented 7 years ago

Hi @mikesamuel , @lukesandberg

Any updates would be very appreciated.

Thanks!

craph commented 7 years ago

Hi @lukesandberg, @mikesamuel, @fenghaolw Any updates would be very appreciated.

Thank you very much!

craph commented 7 years ago

Hi @lukesandberg, @mikesamuel, @fenghaolw,

Sorry for all my comments but can we have the visibility about this issue because my team and I and our projects are still blocked because the documentation and examples in this Github repo doesn't explain the right way on how to use closure template in Javascript with soyutils_usegoog.js.

Can you explain what is the Javascript files of "closure library" we must includes to be able to use soyutils_usegoog.js ?!

Thank you very much!

Best regards.

craph commented 7 years ago

Any news please ?

Thx

craph commented 7 years ago

@vrana , @Ubehebe , @mikesamuel ,

Could you help us about that and explain on how to use soyutils_usegoog.js ? and after that do what @mikesamuel mention :

and then we can start updating documentation to explain how to explain how to use the soy JS runtime with closure explain why it's a really good idea to use closure compiler with soy-generated JS. explain how to use it without closure compiler reiterate 2.

Many thanks to all of us for the help you can provide me because my team and I are still blocked to update the maven version of closure template to the latest version on our ecommerce project.

Best regards

tntim96 commented 7 years ago

How do we use required_by_soy.js? It seems we're still missing the basic name-space creation var goog = goog || {};. I did get that working as described here, but I'm not sure if it's the correct approach for a production release.

When using soy_requirements_onefile.js, I get ReferenceError: soy is not defined

tntim96 commented 7 years ago

I've built a working replacement for soyutils.js with the closure-compiler (see below) and with closurebuilder.py (example in this comment). By working, I mean all our JavaScript and web tests pass. I'd like to use this in production with the 2017-06-22 release of soy. Can anyone (preferably from google) comment on:

  1. Whether this approach is OK (Any other libraries or options I should include? Any shorter way to include dependencies? I had to slowly build that command manually)
  2. closure-compiler vs. closurebuilder.py (I've noticed with closurebuilder.py, I need to set goog.global.CLOSURE_NO_DEPS = true; on the generated JS output. Also compiler output was 232K vs. 806K for the builder - orig soyutils.js file was 71K)
  3. Should I use a specific git tagged version of the closure-library with version 2017-06-22 of soy
  4. The 2012 soyutils.js file was 71K. Why the x10 increase when building with soy_usegoog_lib.js?
java -jar closure-compiler-v20170521.jar --js \
  ../closure-templates-release-2017-06-22/javascript/soyutils_usegoog.js \
  closure/goog/base.js \
  closure/goog/array/array.js \
  closure/goog/asserts/asserts.js \
  closure/goog/debug/debug.js \
  closure/goog/debug/error.js \
  closure/goog/dom/asserts.js \
  closure/goog/dom/browserfeature.js \
  closure/goog/dom/dom.js \
  closure/goog/dom/htmlelement.js \
  closure/goog/dom/nodetype.js \
  closure/goog/dom/safe.js \
  closure/goog/dom/tagname.js \
  closure/goog/dom/tags.js \
  closure/goog/format/format.js \
  closure/goog/fs/url.js \
  closure/goog/functions/functions.js \
  closure/goog/html/legacyconversions.js \
  closure/goog/html/safehtml.js \
  closure/goog/html/safescript.js \
  closure/goog/html/safestyle.js \
  closure/goog/html/safestylesheet.js \
  closure/goog/html/safeurl.js \
  closure/goog/html/trustedresourceurl.js \
  closure/goog/html/uncheckedconversions.js \
  closure/goog/i18n/bidi.js \
  closure/goog/i18n/bidiformatter.js \
  closure/goog/i18n/graphemebreak.js \
  closure/goog/iter/iter.js \
  closure/goog/labs/useragent/browser.js \
  closure/goog/labs/useragent/engine.js \
  closure/goog/labs/useragent/platform.js \
  closure/goog/labs/useragent/util.js \
  closure/goog/object/object.js \
  closure/goog/math/coordinate.js \
  closure/goog/math/math.js \
  closure/goog/math/size.js \
  closure/goog/reflect/reflect.js \
  closure/goog/soy/data.js \
  closure/goog/soy/soy.js \
  closure/goog/string/const.js \
  closure/goog/string/string.js \
  closure/goog/string/typedstring.js \
  closure/goog/structs/inversionmap.js \
  closure/goog/structs/structs.js \
  closure/goog/structs/map.js \
  closure/goog/uri/uri.js \
  closure/goog/uri/utils.js \
  closure/goog/useragent/useragent.js \
  --js_output_file ../closure-templates-release-2017-06-22/soyutils-compiled-release-2017-06-22.js