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.

Compiler not accurately tracking polyfill use of $jscomp.makeIterator

See original GitHub issue

I’m using the Closure Compiler via the Java API in shadow-cljs. I’m using it to process npm packages and polyfill when needed or configured to do so. Recently some code starting throwing at runtime with $jscomp.makeIterator is not a function errors. It appears that some code gets rewritten to use that but the (expected) ensureLibraryInjected("es6/util/makeiterator") never happens. This is also somewhat elusive to reproduce. As far as I can tell es6/util/makeiterator is referenced only by other polyfills so it’ll sometimes be available if you happen to have other code that used those polyfills. If not however it’ll just fail at runtime.

This call seems to create the rewrite: https://github.com/google/closure-compiler/blob/c42989161269278a5c86683be70f4933f5f12333/src/com/google/javascript/jscomp/AstFactory.java#L1115

And it is used in two places https://github.com/google/closure-compiler/blob/023718e521b4f1cb508ff7d177b3d8e50c0ad8d8/src/com/google/javascript/jscomp/Es6ForOfConverter.java#L88 https://github.com/google/closure-compiler/blob/524f612385c836730a194502b30c601090cface6/src/com/google/javascript/jscomp/Es6RewriteDestructuring.java#L626

Neither ensure that the polyfill is actually injected prior to using that.

I’m not entirely sure they are supposed and I have no small reproduction with only the Closure Compiler available as of now but it does happen reliably with my tool as shown in this repro.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
brad4dcommented, Dec 29, 2021

I have a fix for this currently in review.

1reaction
lauraharkercommented, Nov 15, 2021

Thanks, that’s very helpful.

This seems to happen with --language_out=ECMASCRIPT_2015 but not --language_out=ECMASCRIPT5. I suspect it’s an issue with the combo of object spread (unsupported in ES 2015) and array destructuring (ok in ES 2015).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Closure renames static Promise polyfill functions in advanced ...
Compiler used : closure-compiler-v20170423.jar System: Windows 10 Using advanced mode in combination with Promise polyfills breaks certain ...
Read more >
Compiler not accurately tracking polyfill use of $jscomp ...
I'm using it to process npm packages and polyfill when needed or configured to do so. Recently some code starting throwing at runtime...
Read more >
shadow-cljs 2021-11-09 - Slack Archive
I'm trying to get https://github.com/fulcrologic/fulcro-rad-demo running and am having trouble getting the cljs repl working in emacs. I bumped ...
Read more >
command line compiler generates bigger file than the online ...
I am testing google closure compiler on command line. I took the latest version : ... $jscomp.polyfill=function(a,c,b,d){if(c){b=$jscomp.global;a=a.split(".
Read more >
$jscomp not defined in code loaded for clojurescript and reagent
1 Answer 1 ... $jscomp is related to the Closure Compiler and the Polyfills it creates. It might be enough to tweak the...
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