Commit c338941
Support @closureUnaware transpilation using runtime libraries as 'external' names
This adds a new mode to the RuntimeJsLibManager class specifically for @closureUnaware transpilation.
Normally transpilation passes reference runtime library fields by the original, qualified field name, as it appears in the JS file. Examples - "$jscomp.global", "$jscomp.inherits".
In optimized builds: the actual runtime library code is compiled together with the transpiled code.
In --skip_non_transpilation_passes/transpile only builds: the actual runtime library code must be loaded separately, usually via a regular library dependency.
However, for transpilation of @closureUnaware blocks within a larger optimized build, we need to both 1) share runtime library code with the regular optimized build & also minify it, for code size reasons but 2) not break references to the runtime library code from within @closureUnaware blocks.
Naively referring to runtime libraries in @closureUnaware code will break after variable & property renaming runs on the main AST.
So instead, we have to treat the runtime libraries as unknown external code for @closureUnaware transpilation - which is what externs let us do. Then in a followup CL, we'll actually inject the runtime field definitions into the @closureUnaware function as arguments.
PiperOrigin-RevId: 8513644651 parent 34e67e3 commit c338941
File tree
7 files changed
+259
-40
lines changed- src/com/google/javascript/jscomp
- js
- test/com/google/javascript/jscomp
- js
7 files changed
+259
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
781 | 781 | | |
782 | 782 | | |
783 | 783 | | |
784 | | - | |
785 | | - | |
786 | | - | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
787 | 790 | | |
788 | 791 | | |
789 | 792 | | |
790 | 793 | | |
791 | | - | |
| 794 | + | |
792 | 795 | | |
793 | 796 | | |
794 | 797 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
842 | 842 | | |
843 | 843 | | |
844 | 844 | | |
845 | | - | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
846 | 849 | | |
847 | 850 | | |
848 | 851 | | |
| |||
3938 | 3941 | | |
3939 | 3942 | | |
3940 | 3943 | | |
| 3944 | + | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
3941 | 3949 | | |
3942 | 3950 | | |
3943 | 3951 | | |
| |||
Lines changed: 86 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
64 | 73 | | |
65 | 74 | | |
66 | 75 | | |
| |||
155 | 164 | | |
156 | 165 | | |
157 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
158 | 179 | | |
159 | 180 | | |
160 | 181 | | |
| |||
166 | 187 | | |
167 | 188 | | |
168 | 189 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
172 | 198 | | |
173 | 199 | | |
174 | 200 | | |
175 | 201 | | |
176 | 202 | | |
177 | 203 | | |
178 | | - | |
| 204 | + | |
179 | 205 | | |
180 | 206 | | |
181 | 207 | | |
182 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
183 | 212 | | |
184 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
185 | 217 | | |
186 | 218 | | |
187 | | - | |
| 219 | + | |
188 | 220 | | |
189 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
190 | 227 | | |
191 | 228 | | |
192 | 229 | | |
| |||
198 | 235 | | |
199 | 236 | | |
200 | 237 | | |
201 | | - | |
202 | | - | |
| 238 | + | |
| 239 | + | |
203 | 240 | | |
204 | 241 | | |
205 | 242 | | |
| |||
214 | 251 | | |
215 | 252 | | |
216 | 253 | | |
217 | | - | |
| 254 | + | |
218 | 255 | | |
219 | 256 | | |
220 | 257 | | |
221 | 258 | | |
222 | 259 | | |
223 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
224 | 271 | | |
225 | 272 | | |
226 | 273 | | |
| |||
245 | 292 | | |
246 | 293 | | |
247 | 294 | | |
| 295 | + | |
| 296 | + | |
248 | 297 | | |
249 | 298 | | |
250 | 299 | | |
| |||
256 | 305 | | |
257 | 306 | | |
258 | 307 | | |
| 308 | + | |
259 | 309 | | |
260 | 310 | | |
261 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
262 | 328 | | |
263 | 329 | | |
264 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
265 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
266 | 342 | | |
267 | 343 | | |
268 | 344 | | |
| |||
287 | 363 | | |
288 | 364 | | |
289 | 365 | | |
290 | | - | |
| 366 | + | |
291 | 367 | | |
292 | 368 | | |
293 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
2076 | 2077 | | |
2077 | 2078 | | |
2078 | 2079 | | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
2079 | 2103 | | |
2080 | 2104 | | |
2081 | 2105 | | |
| |||
Lines changed: 37 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | | - | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
| |||
293 | 291 | | |
294 | 292 | | |
295 | 293 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
318 | 331 | | |
319 | 332 | | |
320 | 333 | | |
| |||
0 commit comments