From 4100001624a4cc88c61143e2678bf80c2aacd922 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 19 Dec 2018 20:55:52 +0100 Subject: [PATCH] lib: remove unintended access to deps/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This brings DEP0084 to End-of-Life. It is unlikely that this has received much public usage in the first place, so removing should be okay. PR-URL: https://github.com/nodejs/node/pull/25138 Reviewed-By: Colin Ihrig Reviewed-By: Jeremiah Senkpiel Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Tobias Nießen Reviewed-By: Gus Caplan Reviewed-By: Trivikram Kamat --- doc/api/deprecations.md | 9 ++- lib/internal/bootstrap/loaders.js | 4 +- .../parallel/test-require-deps-deprecation.js | 56 ------------------- tools/js2c.py | 18 ------ 4 files changed, 7 insertions(+), 80 deletions(-) delete mode 100644 test/parallel/test-require-deps-deprecation.js diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 3debf8297179ab..8dacce58888324 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1670,16 +1670,19 @@ the client and is now unsupported. Use the `ciphers` parameter instead. ### DEP0084: requiring bundled internal dependencies -Type: Runtime +Type: End-of-Life Since Node.js versions 4.4.0 and 5.2.0, several modules only intended for -internal usage are mistakenly exposed to user code through `require()`. These -modules are: +internal usage were mistakenly exposed to user code through `require()`. These +modules were: - `v8/tools/codemap` - `v8/tools/consarray` diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index af4928cc6163d1..93fb186574165c 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -220,9 +220,7 @@ NativeModule.isDepsModule = function(id) { }; NativeModule.requireForDeps = function(id) { - if (!NativeModule.exists(id) || - // TODO(TimothyGu): remove when DEP0084 reaches end of life. - NativeModule.isDepsModule(id)) { + if (!NativeModule.exists(id)) { id = `internal/deps/${id}`; } return NativeModule.require(id); diff --git a/test/parallel/test-require-deps-deprecation.js b/test/parallel/test-require-deps-deprecation.js deleted file mode 100644 index 5bee24a5db19ce..00000000000000 --- a/test/parallel/test-require-deps-deprecation.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -const common = require('../common'); -const assert = require('assert'); - -const deprecatedModules = [ - 'node-inspect/lib/_inspect', - 'node-inspect/lib/internal/inspect_client', - 'node-inspect/lib/internal/inspect_repl', - 'v8/tools/SourceMap', - 'v8/tools/codemap', - 'v8/tools/consarray', - 'v8/tools/csvparser', - 'v8/tools/logreader', - 'v8/tools/profile', - 'v8/tools/profile_view', - 'v8/tools/splaytree', - 'v8/tools/tickprocessor', - 'v8/tools/tickprocessor-driver' -]; - -// Newly added deps that do not have a deprecation wrapper around it would -// throw an error, but no warning would be emitted. -const deps = [ - 'acorn/dist/acorn', - 'acorn/dist/walk' -]; - -common.expectWarning('DeprecationWarning', deprecatedModules.map((m) => { - return [`Requiring Node.js-bundled '${m}' module is deprecated. ` + - 'Please install the necessary module locally.', 'DEP0084']; -})); - -for (const m of deprecatedModules) { - try { - require(m); - } catch {} -} - -// Instead of checking require, check that resolve isn't pointing toward a -// built-in module, as user might already have node installed with acorn in -// require.resolve range. -// Ref: https://github.com/nodejs/node/issues/17148 -for (const m of deps) { - let path; - try { - path = require.resolve(m); - } catch (err) { - assert.ok(err.toString().startsWith('Error: Cannot find module ')); - continue; - } - assert.notStrictEqual(path, m); -} - -// The V8 modules add the WebInspector to the globals. -common.allowGlobals(global.WebInspector); diff --git a/tools/js2c.py b/tools/js2c.py index 46cf918ba977f6..eff44940c57ec6 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -214,14 +214,6 @@ def ReadMacros(lines): ); """ -DEPRECATED_DEPS = """\ -'use strict'; -process.emitWarning( - 'Requiring Node.js-bundled \\'{module}\\' module is deprecated. Please ' + - 'install the necessary module locally.', 'DeprecationWarning', 'DEP0084'); -module.exports = require('internal/deps/{module}'); -""" - def JS2C(source, target): modules = [] consts = {} @@ -265,15 +257,11 @@ def AddModule(module, source): lines = ExpandConstants(lines, consts) lines = ExpandMacros(lines, macros) - deprecated_deps = None - # On Windows, "./foo.bar" in the .gyp file is passed as "foo.bar" # so don't assume there is always a slash in the file path. if '/' in name or '\\' in name: split = re.split('/|\\\\', name) if split[0] == 'deps': - if split[1] == 'node-inspect' or split[1] == 'v8': - deprecated_deps = split[1:] split = ['internal'] + split else: split = split[1:] @@ -293,12 +281,6 @@ def AddModule(module, source): else: AddModule(name.split('.', 1)[0], lines) - # Add deprecated aliases for deps without 'deps/' - if deprecated_deps is not None: - module = '/'.join(deprecated_deps).split('.', 1)[0] - source = DEPRECATED_DEPS.format(module=module) - AddModule(module, source) - # Emit result output = open(str(target[0]), "w") output.write(