Using modules with uncompiled code

80 views
Skip to first unread message

josh on

unread,
Oct 17, 2011, 3:01:20 PM10/17/11
to Closure Library Discuss
Is it possible to use modules with uncompiled code?

I have a module which requires some classes that are not included in
the main app. I list those classes in the require statements at the
top of my module. I also list those classes in the array of URIs
required for that module.

However, when I call:
"goog.module.ModuleManager.getInstance().setLoaded('MyModule');", at
the end of my module code, the .js files that it is dependent on are
not yet available.

If I used the compiler I imagine that all the classes that this module
uniquely depends on would be contained in a single .js file for that
module.

Is there a way to ensure that all the required js files and their
classes are loaded before I call the constructor on my module?

Should my module extend BaseModule? - none of the examples (in the
test files or in Bolin's book) do.

I would like it to run uncompiled, so that I can set breakpoints on
readable code when I am debugging.

Michael Bolin

unread,
Oct 17, 2011, 3:41:59 PM10/17/11
to Closure Library Discuss
I would recommend using plovr by following the modules example.

Sadly, I have not had a chance to finish writing up all of the
documentation for it: http://plovr.com/modules.html

If you have this setup using plovr, you can debug in RAW or SIMPLE
mode, meaning you can load each file in a module individually or let
plovr glob them together.

John Lenz

unread,
Oct 17, 2011, 5:10:34 PM10/17/11
to closure-lib...@googlegroups.com
The compiler doesn't have a "pass-thru" mode for generating modules, but you can use white-space only and pretty print to get similar results.

Alec

unread,
Oct 18, 2011, 1:49:40 PM10/18/11
to Closure Library Discuss
Thanks John- that worked, we set --compilation_level WHITESPACE_ONLY.

So when we have modules, it is not possible to debug without
compilation in any meaningful way?

John Lenz

unread,
Oct 18, 2011, 5:51:15 PM10/18/11
to closure-lib...@googlegroups.com
You define the modules for the compiler (that is which files that belong to which module), you just need a means of building the modules to serve without the compiler.  Plovr and other tools do this.

Alec

unread,
Oct 18, 2011, 6:33:41 PM10/18/11
to Closure Library Discuss
We compiled with --compilation_level WHITESPACE_ONLY, and we want to
debug a module that is loaded when a user clicks a button. Apparently,
in Closure the module script is brought in with XMLHttpRequest and
then evaluated with eval(), so we cannot put a break point there: the
browser does not show it in Scripts and does not treat it as
javascript.
Is this a problem that cannot be solved without plovr or any other
external tools? We just want to keep our environment as simple as
possible.

Ilia Mirkin

unread,
Oct 18, 2011, 6:42:12 PM10/18/11
to closure-lib...@googlegroups.com
There's another mode for loading modules using script tags. It's a
setting on the module loader...

Alec

unread,
Oct 18, 2011, 7:02:45 PM10/18/11
to Closure Library Discuss
Thanks, module_loader.setDebugMode(true) did the job.
Reply all
Reply to author
Forward
0 new messages