remap polyfills (via $jscomp) without including $jscomp definition in the output
See original GitHub issueWhen splitting the app into “bundles”, sharing $jscomp
definitions between all bundles could be beneficial, especially if the rollups are created by concatenating “bundles” on-demand.
With the new option --inject_library=es6_runtime
we can easily externalize $jscomp
definitions that can be used to patch the environment, but the missing part is how to compile modules with the proper mapping for polyfills without having to include $jscomp
definitions in those other files?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:14 (2 by maintainers)
Top Results From Across the Web
command line compiler generates bigger file than the online ...
$jscomp.polyfill=function(a,c,b,d){if(c){b=$jscomp.global;a=a.split(". ... This tells the compiler not to polyfill Array.prototype.find and also disables ...
Read more >third_party/ink/closure/base.js - chromium/src - Git at Google
you may not use this file except in compliance with the License. ... path (relative to base.js) should define a function $jscomp.transpile.
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 >Download Patch File - OpenDev
defineProperty=$jscomp. ... Object.prototype&&(b[k]=q.value)};$jscomp. ... whose with without", literal:"AppleScript false linefeed return pi quote result ...
Read more >Changelog — thheller/shadow-cljs 2.15.5 - cljdoc
[ 8d0ad ] work arround not being able to ignore @define in npm files; [ bfdda ] fix error message for ... [...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
AFAICT, the purpose of this issue is to request the ability to do something like this.
a.js
,b.js
, andc.js
to createabc_out.js
x.js
,y.js
, andz.js
to createxyz_out.js
abc_out.js
andxyz_out.js
when shipping them to the browser and / or load them independently in the browser.Presumably externs files are used to define the interface between code in the 2 output files. This bug exists because you would need to include the
$jscomp
polyfill code needed to support transpilation only once.A core part of the closure-compiler design is that it should see all of the relevant code, except possibly some external library code that is not compiled. Separately compiling pieces then putting them together later isn’t something we actively try to support.
If the purpose of doing things this way is to reduce the amount of code that must be shipped to the browser, the
--module
flag should be used as @ChadKillingsworth suggested above. With this flag the compiler sees all the code as input, but splits the output into separately loadable files. Here’s his nice SO article about it.https://stackoverflow.com/questions/10395810/how-do-i-split-my-javascript-into-modules-using-googles-closure-compiler/10401030#10401030
@brad4d - given the answer from @shicks here https://github.com/google/closure-compiler/issues/1603 it seems like you kind of can do this ? I think first would need to get the polyfills in a separate output file by compiling an empty source with force inject es6 runtime.
Then you build
abc_out.js
andxyz_out.js
using the optionsetPreventLibraryInjection(true)
. Or presumably you could write a small file that used all the transpilable features you wanted to support and compile that to get the polyfills. You then combine the polyfill and the two output files.