GeezerVison is showing github.com — Expose up-to-date list of builtin modules · Issue #3307 · nodejs/node
Expose up-to-date list of builtin modules #3307Labels feature requestIssues requesting new Node.js features.help wantedIssues that need assistance from volunteers or PRs that need help to proceed. ActivityFishrock123 commented on Oct 10, 2015 Fwiw is-builtin-module uses the builtin-modules module, whose source code is as follows:
'use strict';
var blacklist = [
'freelist',
'sys'
];
module.exports = Object.keys(process.binding('natives')).filter(function (el) {
return !/^_|^internal/.test(el) && blacklist.indexOf(el) === -1;
}).sort();
Specifically, this bit: Object.keys(process.binding('natives')) will stop working in the future.
See:
About the first, process.binding('natives') returns data (the whole damn source code) which cannot be guaranteed not to change. As such we're going to be moving away from it pretty much asap. Fishrock123 commented on Oct 10, 2015 I suggest we have an API that exposes a list of core module names only. piranna commented on Oct 10, 2015 On NodeOS we were thinking about moving out all build-in modules to reduce the size of the binary and it's memory foot print, I think this could be really useful... sindresorhus commented on Oct 11, 2015 👍 As illustrated, doing this in user-land is brittle. ChALkeR commented on Oct 20, 2015 See also: #3078 (comment) and ayecue/node-cjs-deps@b3ea440.
We might want to provide a way to expose a list of _prefixed (but not internal) module names.
For example, require('module').builtinModules for the normal list and require('module')._builtinModules for the full list that includes both normal and _prefixed builtin module names.
And yes, names only.
Note: per doc, this should not be put into the module module, it's Frozen. We need a different place I guess. ChALkeR commented on Oct 20, 2015 trevnorris commented on Oct 20, 2015 Ref: #2180
NM. Different list. Fishrock123 commented on Oct 20, 2015 @trevnorris that's not quite the same though, is it?
Also, should it list internal modules too, or should that be something separate?
I've noticed some things, such as debuggers, apparently rely on knowing what internal modules there are, which is weird. I'd prefer someone to give a solid reason why first. sindresorhus commented on Oct 20, 2015
Also, should it list internal modules too, or should that be something separate?
Only public modules. If there's a need for a list of internal modules, it should be a separate thing. ChALkeR commented on Oct 20, 2015 @Fishrock123 Internal or prefixed? Could you give an example, please? Fishrock123 commented on Oct 20, 2015
Only public modules. If there's a need for a list of internal modules, it should be a separate thing.
Makes sense, I was thinking along these lines too.
@ChALkeR I meant /internal/. Prefixed modules would appear in the regular one as they are potential module name conflicts. hemanth commented on Oct 28, 2015 Trott commented on Oct 28, 2015 @hemanth That looks like it lists all the modules that are automatically loaded by the REPL, but not all the built-ins available in Node. It misses console, constants, module, process, repl, timers and the deprecated modules sys and freelist. hemanth commented on Oct 29, 2015 @Trott Right, we need to work on process.binding('natives') then. apapirovski commented on Dec 12, 2017 @maclover7 do you know if this issue can be closed? I believe your builtinModules PR addressed this? maclover7 commented on Dec 12, 2017
MetadataMetadatafeature requestIssues requesting new Node.js features.help wantedIssues that need assistance from volunteers or PRs that need help to proceed. DevelopmentNo branches or pull requestsIssue actions
|