From 8806ca1e794b5d4757169dd3973d8d436c7707f9 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Thu, 12 Mar 2020 19:18:09 +0100 Subject: [PATCH 1/4] doc: deprecate process.mainModule --- doc/api/deprecations.md | 18 ++++++++++++++++++ doc/api/process.md | 3 +++ 2 files changed, 21 insertions(+) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 075a620b403407..d9b25d94b12657 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2617,6 +2617,22 @@ async function openAndClose() { } ``` + +### DEP0XXX: `process.mainModule` + + +Type: Documentation-only + +[`process.mainModule`][] is a CJS-only feature while `process` global object is +shared with non-CJS environment. + +It's safe to use [`require.main`][] as a replacement. + [`--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 +2690,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 diff --git a/doc/api/process.md b/doc/api/process.md index 88068a0e0caa1b..a979c46bd58240 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1499,8 +1499,11 @@ debugger. See [Signal Events][]. ## `process.mainModule` +> Stability: 0 - Deprecated: Use [`require.main`][] instead. + * {Object} The `process.mainModule` property provides an alternative way of retrieving From 14d35d9a43bc9088bcb591d2d40ca0b197e5e28d Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 12 Mar 2020 19:51:13 +0100 Subject: [PATCH 2/4] Add PR URL Co-Authored-By: Anna Henningsen --- doc/api/deprecations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index d9b25d94b12657..5703cc37d792df 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2622,7 +2622,7 @@ async function openAndClose() { From 8da11915b669c89fd49a34e9d2806004424e8318 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 13 Mar 2020 20:15:45 +0100 Subject: [PATCH 3/4] Apply suggestions from code review --- doc/api/deprecations.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 5703cc37d792df..1f3b714e4be8f2 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2628,10 +2628,12 @@ changes: Type: Documentation-only -[`process.mainModule`][] is a CJS-only feature while `process` global object is -shared with non-CJS environment. +[`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's safe to use [`require.main`][] as a replacement. +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 From a87620eba79f220949e2cc56f1e1e18c101aeae5 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Sun, 15 Mar 2020 00:39:39 +0100 Subject: [PATCH 4/4] fix linter --- doc/api/deprecations.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 1f3b714e4be8f2..461471245349ea 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2628,9 +2628,9 @@ changes: 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. +[`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.