From 043e54790b62953e927d2776925904c4dbc10b52 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Tue, 15 Dec 2015 13:19:56 +0800 Subject: [PATCH 1/2] module: deprecate require('module').Module recommend developers to use `require('module')`. --- lib/module.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/module.js b/lib/module.js index ca2c805bb0da16..033ae81bb64003 100644 --- a/lib/module.js +++ b/lib/module.js @@ -516,5 +516,9 @@ Module._preloadModules = function(requests) { Module._initPaths(); -// backwards compatibility -Module.Module = Module; +Object.defineProperty(Module, 'Module', { + get: internalUtil.deprecate(function() { + return Module; + }, + `require('module').Module is deprecated. Use require('module') instead.`) +}); From 5e67ecaf9ba1b8cdc833f11109895ce6029d569c Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Fri, 15 Jan 2016 17:01:52 +0800 Subject: [PATCH 2/2] events: deprecate require('events').EventEmitter recommend developers to use `require('events')`. --- lib/events.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/events.js b/lib/events.js index f57882ab6dc427..403f2d2ff8cea2 100644 --- a/lib/events.js +++ b/lib/events.js @@ -8,8 +8,13 @@ function EventEmitter() { } module.exports = EventEmitter; -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; +Object.defineProperty(EventEmitter, 'EventEmitter', { + get: internalUtil.deprecate(function() { + return EventEmitter; + }, + `require('events').EventEmitter is deprecated.` + + `Use require('events') instead.`) +}); EventEmitter.usingDomains = false;