Failure with multiple compiled projects

100 views
Skip to first unread message

Marco Gadaleta

unread,
Apr 18, 2016, 8:51:38 AM4/18/16
to plovr
Hi guys,
this is the problem: I have put, under bin folder, two different js files generated by plovr 5.1.
Under my bin this is the tree structure:
-bin
----- a.js (generated with a plovr config file)
----- b.js (generated with another one plovr config file)

The problem is that when I import these js files inside my "index.html" page, in consolle there is this error:
Uncaught Error: Namespace "goog.debug.Error" already declared.
and after an "Uncaught ReferenceError: ...." related to my second loaded file.

In other words the second loaded file in the html page generate a conflict with the first one.
There is a way to manage this kind of problem during compilation?


Thank you very mutch,
Marco

Ilia Mirkin

unread,
Apr 18, 2016, 9:40:01 AM4/18/16
to pl...@googlegroups.com
Use a wrapper.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "plovr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to plovr+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Marco Gadaleta

unread,
Apr 18, 2016, 10:01:20 AM4/18/16
to plovr, imi...@alum.mit.edu
Can you give me an example please?

Ilia Mirkin

unread,
Apr 18, 2016, 10:02:37 AM4/18/16
to pl...@googlegroups.com
http://plovr.org/options.html#output-wrapper

On Mon, Apr 18, 2016 at 10:01 AM, Marco Gadaleta

Marco Gadaleta

unread,
Apr 18, 2016, 10:05:13 AM4/18/16
to plovr, imi...@alum.mit.edu
I don't understand how this option can help me.
I've two different config files that produce two  different js files.
How output-wrapper can help me to fix conflict problem?

Andre Tannus

unread,
Apr 18, 2016, 10:07:20 AM4/18/16
to pl...@googlegroups.com, Ilia Mirkin
It will hide your variables in a closure scope and prevent them from colliding.
It's not magic, you'll still have problemas if the different packages *expose* colliding objects.
André Tannús | Epungo | +55 11 2389-4360
We are a layer

Ilia Mirkin

unread,
Apr 18, 2016, 10:07:33 AM4/18/16
to pl...@googlegroups.com
The (function() { ... })() construct avoids any variables leaking out
of the namespace created by the wrapper. You can still obviously
access window.foo, and IIRC some bits of closure library do that for
id's, so if you use those, you're sunk.

On Mon, Apr 18, 2016 at 10:05 AM, Marco Gadaleta

Marco Gadaleta

unread,
Apr 18, 2016, 10:51:08 AM4/18/16
to pl...@googlegroups.com
I use it in this way:
    "output-wrapper":"(function(){%output%})();",
but in the compiled js I've this kind of error

goog.debug.Error

You received this message because you are subscribed to a topic in the Google Groups "plovr" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/plovr/jZXyzdDqoxY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to plovr+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marco Gadaleta
In the meantime, stay curious, ambitious, daring, and above all, stay adventurous!

Nick Santos

unread,
Apr 18, 2016, 2:31:25 PM4/18/16
to pl...@googlegroups.com
I think you need to provide more context on what you're trying to do.
Maybe share your plovr configs?

On Mon, Apr 18, 2016 at 10:51 AM, Marco Gadaleta

Marco Gadaleta

unread,
Apr 19, 2016, 3:15:13 AM4/19/16
to plovr
Sure,
i add the attachments
configMWidgets.js
configFrmk.js

Andre Tannus

unread,
Apr 19, 2016, 8:09:40 AM4/19/16
to pl...@googlegroups.com
I think I've ran into this before. I'm speaking from memory, so I may be wrong.

Does it work when you use a compile mode other than WHITESPACE? (Like RAW).

Marco Gadaleta

unread,
Apr 19, 2016, 8:42:13 AM4/19/16
to pl...@googlegroups.com
The compilation works well.
I think that could be something in the code that break the complied file (but i've no error during compilation).

So thanks for the help and i try to understand where is the problem in the code.

Andre Tannus

unread,
Apr 19, 2016, 8:44:50 AM4/19/16
to pl...@googlegroups.com
It should not break when compiled, only in WHITESPACE.
I think I mentioned it in this forum a while back.

Andre Tannus

unread,
Apr 19, 2016, 8:46:44 AM4/19/16
to pl...@googlegroups.com

Marco Gadaleta

unread,
Apr 19, 2016, 8:57:13 AM4/19/16
to pl...@googlegroups.com
It's the same problem

Nick Santos

unread,
Apr 19, 2016, 4:41:58 PM4/19/16
to pl...@googlegroups.com
I don't think it's possible to accomplish what you're trying to do.
The solution that you're trying (load closure-library twice on the
same page without compilation) is not supported by closure-library.
You have two options:

1) Compile both versions with SIMPLE or ADVANCED, and create an output
wrapper around each.
2) Use the closure-library code-loader (goog.require) to load both,
and let it de-dupe the common dependencies.

If you have questions about this, you're probably better off asking on
the closure-library-discuss mailing list.

On Tue, Apr 19, 2016 at 8:57 AM, Marco Gadaleta
Reply all
Reply to author
Forward
0 new messages