Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing some builtins #2

Closed
billiegoose opened this issue Oct 9, 2017 · 4 comments
Closed

Missing some builtins #2

billiegoose opened this issue Oct 9, 2017 · 4 comments

Comments

@billiegoose
Copy link

These are builtin modules that are part of the undocumented "private" core API but are unfortunately shimmed in browserify, and some module authors continue to prefer them over the public builtins because using them shaves a few kb off of their bundle size:

_stream_duplex
_stream_passthrough
_stream_readable
_stream_transform
_stream_writable

My root problem is that my test-runner, jest, does not recognize _stream_transform as a core module and breaks as a result. You can see I originally tried to fix it here in the module that requires _stream_transform, but as switching from _stream_transform to stream would have increased the bundle size, I am now looking for other solutions. If you are willing to add them to this module that would be great. If not (for whatever reason) I will approach jest-resolve and see if it can be addressed there.

@sindresorhus
Copy link
Owner

I don't want to encourage using private core API's. They're private for a reason, and using them makes it more difficult for the Node.js core team to do important changes. If it's really needed, it should be added by the specific module that needs it. Not here.

@billiegoose
Copy link
Author

I understand your intentions, but I am frustrated by the historical inconsistency from both Node core and the userspace around what constitutes the "private core" API vs the "public core" API. For instance, you include the "constants" module in your list. It is not a documented part of the public API - why include it?

@trusktr
Copy link

trusktr commented Mar 3, 2020

Also, for practical purposes, tools like Webpack need to know the exact list of built-in module if one wishes for Webpack not to bundle those. People shouldn't use the private APIs, but people still need the entire list for practical purposes.

@trusktr
Copy link

trusktr commented Mar 3, 2020

In case anyone stumbles here, this is Node.js API for querying the list of all builtin modules:

const builtin = require('module').builtinModules;

and example of the output in Node repl:

> require('module').builtinModules
[
  '_http_agent',       '_http_client',        '_http_common',
  '_http_incoming',    '_http_outgoing',      '_http_server',
  '_stream_duplex',    '_stream_passthrough', '_stream_readable',
  '_stream_transform', '_stream_wrap',        '_stream_writable',
  '_tls_common',       '_tls_wrap',           'assert',
  'async_hooks',       'buffer',              'child_process',
  'cluster',           'console',             'constants',
  'crypto',            'dgram',               'dns',
  'domain',            'events',              'fs',
  'http',              'http2',               'https',
  'inspector',         'module',              'net',
  'os',                'path',                'perf_hooks',
  'process',           'punycode',            'querystring',
  'readline',          'repl',                'stream',
  'string_decoder',    'sys',                 'timers',
  'tls',               'trace_events',        'tty',
  'url',               'util',                'v8',
  'vm',                'worker_threads',      'zlib'
]

The doc for that (including supported Node versions) is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants