whitespace mode not working work with output-wrapper

64 views
Skip to first unread message

Andre Tannus

unread,
May 15, 2012, 7:15:41 PM5/15/12
to pl...@googlegroups.com
I've just run into something weird when running plovr with the combination

"mode": "WHITESPACE",
"output-wrapper": "(function(){%output%})();"

After all dependencies are loaded,

goog.provide('goog.debug.Error');
goog.debug.Error = function() {...} Cannot set property 'Error' of undefined

I went into goog.provide and noticed that goog.exportPath() is actually setting "goog" in the Window object (DOMWindow), whereas the 'goog' object is inside the wrapping closure.
As a result, WHITESPACE mode won't work in a function wrapper.

Is this expected?

--
A ciência consiste em perturbar um sistema e analisar sua reação. Eu, sou uma perturbação.

André Tannús | Ideas at Epungo
ata...@epungo.com.br | +55 11 8053-7636 | +55 11 2389-4360 

"Somewhere, something incredible is waiting to be known."
Carl Sagan

Marco Gadaleta

unread,
Apr 29, 2016, 6:50:59 AM4/29/16
to plovr
Are you able to solve this problem?

Andre Tannus

unread,
Apr 29, 2016, 10:47:39 AM4/29/16
to pl...@googlegroups.com
No, I just never use WHITESPACE anymore.

--

---
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.



--
André Tannús | Epungo | +55 11 2389-4360
We are a layer

John Lenz

unread,
Apr 29, 2016, 11:04:26 AM4/29/16
to pl...@googlegroups.com
There is no way for goog.provide to introduce a variable within the function wrapper, so you can workaround it by modifying base.js and your output wrapper:

"output-wrapper": "var goog = {};(function(){%output%})();"

But the function wrapper won't provide the expected protection/isolation as all of "goog" namespace will now be global.  This issue will exist for any explicitly declared global namespace.   The alternative is to explicitly declare all of the top level namespaces but Closure Library isn't built that way.

Marco Gadaleta

unread,
Apr 29, 2016, 11:32:05 AM4/29/16
to pl...@googlegroups.com
I fixed it using this configuration:
{
  "id": "frmk_pxc",
  "inputs": [
    // SYSTEM-LIBRARY
    "../../src/importing-lib/deflib.js",
    "../../src/frmk/frmk.js"
  ],
  "paths": [
    "...."
  ],
  "externs": [
    "...."       
  
    ],
  "output-wrapper": "(function(){%output%})();",
  "mode": "SIMPLE",// //"RAW", "WHITESPACE", "SIMPLE", or "ADVANCED". 
  "level": "QUIET"//"QUIET", "DEFAULT", or "VERBOSE"
  /* ,"jsdoc-html-output-path":"/wkp/doc" */
}

And defining  goog.exportSymbol for each class that interact with an html file.

Marco

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/CU1RmOsX1tw/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!
Reply all
Reply to author
Forward
0 new messages