Compile service worker without creating window.__wpcc

13 views
Skip to first unread message

taha soft

unread,
Jul 27, 2022, 1:38:49 PM7/27/22
to Closure Compiler Discuss
When I compile a serviceworker code, the result is wrapped with a immediately invoked function expression like this

(function(__wpcc){
  // code goes here
}).call(this || window, (window.__wpcc = window.__wpcc || {}));

As you know service worker has no window object, which break it in my case.
How can I compile without the wrapping weird function

lha...@google.com

unread,
Jul 27, 2022, 1:52:46 PM7/27/22
to Closure Compiler Discuss
Closure Compiler has no built-in logic that would add a reference to a __wpcc property.

Looks like your config or the config from a tool you're using is passing an --output_wrapper flag, with the IIFE you mentioned.

I think we need more information about how you're calling Closure Compiler.
Reply all
Reply to author
Forward
0 new messages