doc: deprecate process.mainModule

PR-URL: https://github.com/nodejs/node/pull/32232
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Antoine du HAMEL 2020-03-12 19:18:09 +01:00 committed by Anna Henningsen
parent 6ade42bb3c
commit f571b294f5
No known key found for this signature in database
GPG Key ID: A94130F0BFC8EBE9
2 changed files with 23 additions and 0 deletions

View File

@ -2617,6 +2617,24 @@ async function openAndClose() {
}
```
<a id="DEP0138"></a>
### DEP0138: `process.mainModule`
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/32232
description: Documentation-only deprecation.
-->
Type: Documentation-only
[`process.mainModule`][] is a CommonJS-only feature while `process` global
object is shared with non-CommonJS environment. Its use within ECMAScript
modules is unsupported.
It is deprecated in favor of [`require.main`][], because it serves the same
purpose and is only available on CommonJS environment.
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
[`--throw-deprecation`]: cli.html#cli_throw_deprecation
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
@ -2674,8 +2692,10 @@ async function openAndClose() {
[`os.networkInterfaces()`]: os.html#os_os_networkinterfaces
[`os.tmpdir()`]: os.html#os_os_tmpdir
[`process.env`]: process.html#process_process_env
[`process.mainModule`]: process.html#process_process_mainmodule
[`punycode`]: punycode.html
[`require.extensions`]: modules.html#modules_require_extensions
[`require.main`]: modules.html#modules_accessing_the_main_module
[`request.socket`]: http.html#http_request_socket
[`request.connection`]: http.html#http_request_connection
[`response.socket`]: http.html#http_response_socket

View File

@ -1499,8 +1499,11 @@ debugger. See [Signal Events][].
## `process.mainModule`
<!-- YAML
added: v0.1.17
deprecated: REPLACEME
-->
> Stability: 0 - Deprecated: Use [`require.main`][] instead.
* {Object}
The `process.mainModule` property provides an alternative way of retrieving