Skip to content

Commit 4f47503

Browse files
authored
Only mark _scriptDir as extern in MODULARIZE mode. NFC (#21734)
Outside of `MODULARIZE` this is just a normal variable that can/should be minified.
1 parent 328db49 commit 4f47503

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

src/closure-externs/closure-externs.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,6 @@ var removeEventListener = function (type, listener) {};
196196
*/
197197
var close;
198198

199-
// Due to the way MODULARIZE works, Closure is run on generated code that does not define _scriptDir,
200-
// but only after MODULARIZE has finished, _scriptDir is injected to the generated code.
201-
// Therefore it cannot be minified.
202-
/**
203-
* @suppress {duplicate, undefinedVars}
204-
*/
205-
var _scriptDir;
206-
207199
// Closure run on asm.js uses a hack to execute only on shell code, declare externs needed for it.
208200
/**
209201
* @suppress {undefinedVars}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Due to the way MODULARIZE works, Closure is run on generated code that does not define _scriptDir,
2+
// but only after MODULARIZE has finished, _scriptDir is injected to the generated code.
3+
// Therefore it cannot be minified.
4+
/**
5+
* @suppress {duplicate, undefinedVars}
6+
*/
7+
var _scriptDir;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6104
1+
6098
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13481
1+
13448

tools/building.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ def closure_compiler(filename, advanced=True, extra_closure_args=None):
555555
# should not minify these symbol names.
556556
CLOSURE_EXTERNS = [path_from_root('src/closure-externs/closure-externs.js')]
557557

558+
if settings.MODULARIZE:
559+
CLOSURE_EXTERNS += [path_from_root('src/closure-externs/modularize-externs.js')]
560+
558561
if settings.USE_WEBGPU:
559562
CLOSURE_EXTERNS += [path_from_root('src/closure-externs/webgpu-externs.js')]
560563

0 commit comments

Comments
 (0)