From ccaebdef66f62775ff8cc5d6fa21881a883c08fc Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 6 Feb 2019 17:42:24 +0200 Subject: [PATCH] esm: process proxy Symbol.toString fix PR-URL: https://github.com/nodejs/node/pull/25963 Reviewed-By: John-David Dalton Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Ruben Bridgewater --- lib/internal/bootstrap/node.js | 6 ++++++ test/es-module/test-esm-process.mjs | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 test/es-module/test-esm-process.mjs diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 03d49b487a56bb..eb1f3e582045ae 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -309,6 +309,12 @@ function setupProcessObject() { const origProcProto = Object.getPrototypeOf(process); Object.setPrototypeOf(origProcProto, EventEmitter.prototype); EventEmitter.call(process); + Object.defineProperty(process, Symbol.toStringTag, { + enumerable: false, + writable: false, + configurable: false, + value: 'process' + }); // Make process globally available to users by putting it on the global proxy Object.defineProperty(global, 'process', { value: process, diff --git a/test/es-module/test-esm-process.mjs b/test/es-module/test-esm-process.mjs new file mode 100644 index 00000000000000..24cf489a988565 --- /dev/null +++ b/test/es-module/test-esm-process.mjs @@ -0,0 +1,6 @@ +// Flags: --experimental-modules +import '../common'; +import assert from 'assert'; +import process from 'process'; + +assert.strictEqual(Object.prototype.toString.call(process), '[object process]');