How to develop and deploy?

瀏覽次數:104 次
跳到第一則未讀訊息

Dave

未讀,
2010年3月3日 下午6:44:102010/3/3
收件者:Closure Library Discuss
I've read through most of the docs on the compiler, calcdeps, etc. and
read through several threads in this group. So far it seems very
complicated to develop and deploy a project based on the library. I
want to love Closure, but I've spent 2 days just trying to get things
organized.

I don't think my requirements are anything unusual. I want to develop
my Javascript code in several files organized by class. Ideally I
could serve these locally during development without calcdeps or the
compiler. When everything is working, I want to flip a switch, compile
everything, and deploy my all-inclusive minimized script.

From what I've read I would need to run calcdeps to create a deps file
for my code, and then remember to update it every time my requires
statements change. And then when I'm ready to deploy, I need compile
with a big fur-ball calcdeps/compiler command line, modify html, etc.
Sounds painful and error-prone.

I read mention of a replacement for calcdeps. How's that going? Is
anybody working to make the develop/deploy process easier?

Thanks,
Dave

Evgeny

未讀,
2010年3月3日 晚上8:03:142010/3/3
收件者:Closure Library Discuss
Hello Dave,

I hear your pain - same story here, but I am closer to making some
progress now ;)

Take a look at this thread:
http://groups.google.com/group/closure-library-discuss/browse_thread/thread/4f4d80566736eed0

Probably the best thing to do is to get the unfinished book by Michael
Bolin (getting which by the way may present yet another challenge :).
safari online site seems to be only partially functional at some
network locations.

Other than that - get your hands on the calcdeps script, compiler and
JSDoc tags and calculating code maps.

Install closure inspector on a Firefox/Firebug (I yet have to find a
combination of FF/FB that works with the inspector - the latest
version does not work on my XP box)

Probably it is the most convenient is to complile code through the
calcdeps.py

Finally I wish google people adopted something better than this groups
software - quite impossible to find things unless you read every post
daily.

Anyway - I hope things will change in the future for the better. It's
quite always difficult to pick up technology that is just at the
beginning of the adoption wave.

Best regards,
Evgeny.

Evgeny

未讀,
2010年3月3日 晚上8:28:332010/3/3
收件者:Closure Library Discuss
http://code.google.com/closure/library/docs/calcdeps.html
calcdeps.py
http://code.google.com/closure/compiler/docs/js-for-compiler.html
JSDoc annotations for closure compiler
http://code.google.com/closure/compiler/docs/inspector.html
closure inspector

firefox & firebug - which versions work with the inspector - still a
mystery for me.

http://code.google.com/p/closure-library/w/list
wiki
http://my.safaribooksonline.com/9781449381882
closure: definitive guide

here I've posted an answer about using calcdeps.py to compile entire
project (I don't really care about stackoverflow votes, but I like
that you can highlight syntax more or less properly there)
http://stackoverflow.com/questions/1691969/how-to-use-googles-closure-to-compile-javascript/2367039#2367039

Please share your success stories!

Cheers.
Evgeny.

On Mar 3, 5:03 pm, Evgeny <evgeny.fad...@gmail.com> wrote:
> Hello Dave,
>
> I hear your pain - same story here, but I am closer to making some
> progress now ;)
>

> Take a look at this thread:http://groups.google.com/group/closure-library-discuss/browse_thread/...

Evgeny

未讀,
2010年3月3日 晚上8:48:272010/3/3
收件者:Closure Library Discuss
here is a link to firefox releases - may be handy to locate version of
browser that works with the inspector

ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/

On Mar 3, 5:28 pm, Evgeny <evgeny.fad...@gmail.com> wrote:
> http://code.google.com/closure/library/docs/calcdeps.html
> calcdeps.pyhttp://code.google.com/closure/compiler/docs/js-for-compiler.html
> JSDoc annotations for closure compilerhttp://code.google.com/closure/compiler/docs/inspector.html


> closure inspector
>
> firefox & firebug - which versions work with the inspector - still a
> mystery for me.
>
> http://code.google.com/p/closure-library/w/list

> wikihttp://my.safaribooksonline.com/9781449381882


> closure: definitive guide
>
> here I've posted an answer about using calcdeps.py to compile entire
> project (I don't really care about stackoverflow votes, but I like

> that you can highlight syntax more or less properly there)http://stackoverflow.com/questions/1691969/how-to-use-googles-closure...

Nick Santos

未讀,
2010年3月3日 晚上10:53:072010/3/3
收件者:closure-lib...@googlegroups.com
On Wed, Mar 3, 2010 at 6:44 PM, Dave <dualr...@gmail.com> wrote:
>
> I read mention of a replacement for calcdeps. How's that going? Is
> anybody working to make the develop/deploy process easier?

In my ideal development scenario, I'd have a server that has a debug
mode and a production mode. In debug mode, it'd serve the raw files
directly. In production mode, it'd compile the scripts at boot-time
and served the compile bundle. Of course, it'd need to be smart enough
to find all the files and compute the dependencies between them.

I don't think we're anywhere near that right now. Things are getting
better, and as you noted Nathan is working on better versions of the
current tools.

I feel like the best deployment solutions will be the ones that
integrate well with a particular server engine or IDE or command-line
setup, so I'd be curious to know what you had in mind.

Nick

Evgeny

未讀,
2010年3月3日 晚上11:39:502010/3/3
收件者:Closure Library Discuss
I've started this wiki page.

http://code.google.com/p/closure-library/wiki/GettingSartedWithClosure

I think there should be some guide that takes people to production
use as soon as possible without sugar-coating the difficult parts
or focusing too much on how you can get by without using all
the real tools like the compiler and inspector.

Something that has the right pointers, key links and explanation of
the
most difficult gotchas.

How do you make Inspector to work and load code maps?
The best I'm getting so far is error - "map cannot be loaded"
or something like that. I am giving it a valid url -
the same url works in the browser fine.

The inspector itself installed from the fifth attempt, but still can't
load maps.

I prefer to use compiler right from the outset because it gives
useful information right at the beginning and forces to document the
code properly. Not to say that it's pretty cool to build the
compressed code like that.
The hardest part so far has been to put all
the pieces together, not as much as the programming issues.

Hopefully we can put together some document that is right to
the point and really helps to get over these hurdles quickly.

Best wishes,
Evgeny.


On Mar 3, 7:53 pm, Nick Santos <nicksan...@google.com> wrote:

Dave

未讀,
2010年3月26日 凌晨12:24:332010/3/26
收件者:Closure Library Discuss
Thanks for the great advice. To tell you the truth, soon after posting
my question here I gave up on Closure and went on to use YUI. After
uses a couple of simple controls, the download size is incredibly
large. So now I'm back looking at Closure again. Looks like the
Closure book is further along and there has been some work on the
dependency script.

Dave

Mohamed Mansour

未讀,
2010年3月26日 上午9:41:152010/3/26
收件者:closure-lib...@googlegroups.com
Hi Dave, 

If you have any questions regarding development and deployment of Closure, let me (us), know. I have spent a good amount of hours trying to figure out how closure thinks. I ended up reading the python scripts to really know whats going on, and to tell you the truth, it is easier than many people think.

1) Develop normally, using goog.provides (like packages in Java with addition to its class name)
2) Use goog.requires for all the classes you want to import.
3) For Development: run calcdeps.py (or the new one), some tricks are needed because the deps file must be relative to goog/base.js
4) For Deployment: run the compiler 

After you get the hang of it, development would be easy and very cool to do!

-
Mohamed Mansour
m...@chromium.org


To unsubscribe from this group, send email to closure-library-discuss+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Evgeny

未讀,
2010年3月28日 凌晨1:52:442010/3/28
收件者:Closure Library Discuss
Hi Dave,

the most helpful part for me was the book by michael bolin "closure
the definitive guide"
it's getting closer to be finished. All the other resources
(particularly links from the wiki and the project site) are helpful
too.

on the practical side here is what I do (but maybe there is a better
way)

I have two shell scripts, one of which calls closure compiler and
template compiler and another compiles just templates.
sometimes it helps to just recompile the templates.

the javascript you can run uncompiled in the development mode.
if your code modifications do not change dependencies, then you can
just refresh the browser window and reload changed sources
but any time you change templates they need to be recompiled.

I do not use closure inspector - never had luck with it yet - plus
there is no need
if you can have your browser load all the sources in uncompiled form
through dependencies.

I use closure compiler just to check my code, not to produce the
compressed output yet (but it can be done with an extra flag)
i'm still using calcdeps.py to create dependency script just for my
project files (but I've heard there is a better tool now)

Template compiler script:
#!/bin/sh
JAR_PATH=/path/to/lib/with/jars
rm soy_generated/*.js
#compile all soy templates so that output works with closure
java -jar $JAR_PATH/SoyToJsSrcCompiler.jar \
--outputPathFormat soy_generated/{INPUT_FILE_NAME_NO_EXT}.js \
--shouldProvideRequireSoyNamespaces \
`find soy -name '*.soy'`

Main compiler script
#!/bin/sh
CALCDEPS_PATH=/path/to/google-closure/closure/bin
JAR_PATH=/path/to/my/lib
CLOSURE_PATH=/path/to/google-closure
#SOY_PATH=/path/to/soy
#C_FLAGS='--compilation_level ADVANCED_OPTIMIZATIONS'
# --compiler_flags=$C_FLAGS \
# --compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS" \

sh compile_soy

#for development I thow away the compiled script
#but use compiler warnings to check errors
$CALCDEPS_PATH/calcdeps.py --path=$CLOSURE_PATH \
--path=. \
--compiler_jar=$JAR_PATH/compiler.jar \
--input=main_script.js \
--output_mode=compiled \
--compiler_flags="--warning_level=VERBOSE"
\
> /dev/null

rm nmr-deps.js
$CALCDEPS_PATH/calcdeps.py --path=. \
--input=main_script.js \
--output_mode=deps \
> my-deps.js

#this perl script will do some path substitutions in the generated
deps file
#you'll have to adjust this so that paths are relative to goog/base.js
perl -pi -w -e "s/addDependency\('/addDependency('..\/..\/..\/myprog
\//" my-deps.js

finally, my html that I use for development looks like this (just the
outline, not exact code):

<html>
<head>
..... all the css needed for the UI, etc
<script src="goog/base.js">
<script src="my-project-deps.js">
<script src="my-main-script.js">
<!-- above is main uncompiled script the rest will be loaded by goog/
base.js using the deps file -->
</head>
<body>
<script>
launch_my_app();
</script>
</body>
</html>

Evgeny.

回覆所有人
回覆作者
轉寄
0 則新訊息