diff options
Diffstat (limited to 'lib/internal/bootstrap/pre_execution.js')
-rw-r--r-- | lib/internal/bootstrap/pre_execution.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index c38822bd89..233ab4f879 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -1,6 +1,7 @@ 'use strict'; const { getOptionValue } = require('internal/options'); +const { Buffer } = require('buffer'); function prepareMainThreadExecution() { // Patch the process object with legacy properties and normalizations @@ -221,6 +222,33 @@ function initializeDeprecations() { 'process.binding() is deprecated. ' + 'Please use public APIs instead.', 'DEP0111'); } + + // Create global.process and global.Buffer as getters so that we have a + // deprecation path for these in ES Modules. + // See https://github.com/nodejs/node/pull/26334. + let _process = process; + Object.defineProperty(global, 'process', { + get() { + return _process; + }, + set(value) { + _process = value; + }, + enumerable: false, + configurable: true + }); + + let _Buffer = Buffer; + Object.defineProperty(global, 'Buffer', { + get() { + return _Buffer; + }, + set(value) { + _Buffer = value; + }, + enumerable: false, + configurable: true + }); } function setupChildProcessIpcChannel() { |