question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: $jscomp is not defined

See original GitHub issue

Hello! I’ve downloaded the most recent version of compiler and i’ve tried to optimize js code with these flags: java -jar closure-compiler-v20211006.jar -W VERBOSE -O WHITESPACE_ONLY --language_out ECMASCRIPT5 $script_path_in --js_output_file $script_path_tmp

closure compiler has optimized this lines of code:

for(var extraProperty of extraProperties){
		option.setAttribute(extraProperty,initialOption[extraProperty]);
	}

into

 for (var $jscomp$iter$0 = $jscomp.makeIterator(extraProperties), $jscomp$key$extraProperty = $jscomp$iter$0.next(); !$jscomp$key$extraProperty.done; $jscomp$key$extraProperty = $jscomp$iter$0.next()) {
        var extraProperty = $jscomp$key$extraProperty.value;
        {
            option.setAttribute(extraProperty, initialOption[extraProperty])
        }
    }

And as a result i receive such error in browser: all_compressed.js Uncaught ReferenceError: $jscomp is not defined

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
roman01lacommented, Jul 20, 2022

The problem described in the original post is that we really shouldn’t allow both WHITESPACE_ONLY mode and transpilation. That’s a contradiction. If you’re transpiling, then you’re not changing only whitespace.

I believe @blickly is working on a change that will adapt WHITESPACE_ONLY to automatically disable transpilation.

@brad4d was that implemented already? We are hitting the same issue in ClojureScript (which relies on Closure) where $jscomp is undefined when language out is set to es5. Is there a workaround that doesn’t involve setting optimizations to simple? We’ve started seeing it after upgrade of Closure from v20210505 to v20220601

0reactions
stigicommented, Jul 20, 2022

@brad4d Here’s a repository demoing a tiny reproduction case for the issue @roman01la mentioned. In our case the issue seems to be rooted in ES6 classes that extend from other classes and $jscomp.inherits being undefined: https://github.com/stigi/clojurescript-es5-issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: $jscomp is not defined · Issue #40 - GitHub
Works with :simple optimizations. Breaks like this with :whitespace optimizations: ❯ clj -M:test -x chrome-headless Chrome Headless 88.0.
Read more >
$jscomp not defined in code loaded for clojurescript and reagent
0, I am running into an error in which a file index.js tries to reference $jscomp , which is not defined. I've seen...
Read more >
JS Console error on Minification - Adobe Experience League ...
Solved: When try to Minify files under clientlibs using JsProcessor, facing some Console errors and the files are not minified too. Console -...
Read more >
Error '$jscomp is not defined' When Publishing Plugin
I am having the same issue with a private plugin that works on the developer's account but not on mine. I get the...
Read more >
ReferenceError: $jscomp is not defined
Hi, Just downloaded yesterday the latest trial version of Siesta, v5.1.1, but can't run any launcher. My server hosts siesta folder, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found