google / closure-compiler

A JavaScript checker and optimizer.
https://developers.google.com/closure/compiler/
Apache License 2.0
7.41k stars 1.15k forks source link

[JSC_UNDEFINED_VARIABLE] variable console is undeclared #4195

Closed 0wwafa closed 1 month ago

0wwafa commented 1 month ago

I have a nodejs program in commonJS. it works normally, it also works with SIMPLE optimization.. but not with ADVANCED and gives these errors:

shell.js:56:13: ERROR - [JSC_UNDEFINED_VARIABLE] variable console is undeclared 56| DEBUG && console.log('\nCFGFILE:\n',cfgfile); ^^^^^^^

shell.js:73:8: ERROR - [JSC_UNDEFINED_VARIABLE] variable process is undeclared 73| process.exit(); // Exit the server process ^^^^^^^

shell.js:84:21: ERROR - [JSC_UNDEFINED_VARIABLE] variable signal is undeclared 84| const id = await signal.send( ^^^^^^

shell.js:191:8: ERROR - [JSC_UNDEFINED_VARIABLE] variable setTimeout is undeclared 191| setTimeout(() => process.exit(code), 1000);

why?!

rishipal commented 1 month ago

In advanced mode you would need to specify externs used in your JS code. See -