pub fn install_entry_globals(origin: &str)Expand description
Install the CJS wrapper variables the ENTRY script sees.
A required module already receives exports/require/module/__dirname
/__filename as wrapper parameters (see compile_wrapper); the entry
script used to receive none of them, so typeof module was "undefined"
there and every UMD header took its browser branch. Node gives the entry
script the same five names, with values that DEPEND ON THE ENTRY POINT:
node f.js | node -e | node - / piped | |
|---|---|---|---|
__filename | resolved abs path | [eval] | [stdin] |
__dirname | its directory | . | . |
module.id | . | [eval] | [stdin] |
module.path | its directory | . | . |
module.filename is path.resolve(__filename) in every case, so under -e
it is <cwd>/[eval] — a path that does not exist, which is Node’s own
value. Measured on node v26.7.0.
origin is the __filename value: an absolute script path, or [eval] /
[stdin] for the two source-on-the-command-line entry points.