如何在没有内部模块的情况下构buildnode.js?

我想build立一个特定的nodejs作为一个静态库,没有像child_process dns等一些内部模块

有没有一个可configuration的方式来解决这个问题?

从node.gyp中删除不需要的模块,从lib文件夹中删除.js文件,将它们从lib/internal/module.jsbuiltinLibs数组中lib/internal/module.js然后构build它。

 { 'variables': { 'v8_use_snapshot%': 'false', 'v8_trace_maps%': 0, 'node_use_dtrace%': 'false', 'node_use_lttng%': 'false', 'node_use_etw%': 'false', 'node_use_perfctr%': 'false', 'node_no_browser_globals%': 'false', 'node_use_v8_platform%': 'true', 'node_use_bundled_v8%': 'true', 'node_shared%': 'false', 'force_dynamic_crt%': 0, 'node_module_version%': '', 'node_shared_zlib%': 'false', 'node_shared_http_parser%': 'false', 'node_shared_cares%': 'false', 'node_shared_libuv%': 'false', 'node_use_openssl%': 'true', 'node_shared_openssl%': 'false', 'node_v8_options%': '', 'node_enable_v8_vtunejit%': 'false', 'node_core_target_name%': 'node', 'library_files': [ 'lib/internal/bootstrap_node.js', 'lib/async_hooks.js', 'lib/assert.js', 'lib/buffer.js', 'lib/child_process.js', //Remove this line 'lib/console.js', 'lib/constants.js', 'lib/crypto.js', 'lib/cluster.js', 'lib/dgram.js', 'lib/dns.js', //Remove this line too [...] 

请注意,这些模块在testing和基准testing中使用,例如在lib/internal/v8_prof_polyfill.jslib/internal/cluster/master.js

Interesting Posts