Skip to content

Commit be83130

Browse files
committed
src: put bootstrappers in lib/internal/bootstrap/
Create `lib/internal/bootstrap/` and put bootstrappers there: Before: ``` lib/internal ├── ... ├── bootstrap_loaders.js └── bootstrap_node.js ``` After: ``` lib/internal ├── ... └── bootstrap ├── loaders.js └── node.js ``` PR-URL: nodejs#19177 Refs: nodejs#19112 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 8ce8889 commit be83130

20 files changed

Lines changed: 65 additions & 62 deletions
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// modules. In contrast, user land modules are loaded using
33
// lib/module.js (CommonJS Modules) or lib/internal/loader/* (ES Modules).
44
//
5-
// This file is compiled and run by node.cc before bootstrap_node.js
5+
// This file is compiled and run by node.cc before bootstrap/node.js
66
// was called, therefore the loaders are bootstraped before we start to
77
// actually bootstrap Node.js. It creates the following objects:
88
//
@@ -29,7 +29,7 @@
2929
// so they can be loaded faster without the cost of I/O. This class makes the
3030
// lib/internal/*, deps/internal/* modules and internalBinding() available by
3131
// default to core modules, and lets the core modules require itself via
32-
// require('internal/bootstrap_loaders') even when this file is not written in
32+
// require('internal/bootstrap/loaders') even when this file is not written in
3333
// CommonJS style.
3434
//
3535
// Other objects:
@@ -114,7 +114,7 @@
114114
// Think of this as module.exports in this file even though it is not
115115
// written in CommonJS style.
116116
const loaderExports = { internalBinding, NativeModule };
117-
const loaderId = 'internal/bootstrap_loaders';
117+
const loaderId = 'internal/bootstrap/loaders';
118118
NativeModule.require = function(id) {
119119
if (id === loaderId) {
120120
return loaderExports;
@@ -214,6 +214,6 @@
214214
};
215215

216216
// This will be passed to the bootstrapNodeJSCore function in
217-
// bootstrap_node.js.
217+
// bootstrap/node.js.
218218
return loaderExports;
219219
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// to the performance of the startup process, many dependencies are invoked
66
// lazily.
77
//
8-
// Before this file is run, lib/internal/bootstrap_loaders.js gets run first
8+
// Before this file is run, lib/internal/bootstrap/loaders.js gets run first
99
// to bootstrap the internal binding and module loaders, including
1010
// process.binding(), process._linkedBinding(), internalBinding() and
1111
// NativeModule. And then { internalBinding, NativeModule } will be passed

lib/internal/loader/ModuleJob.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { internalBinding } = require('internal/bootstrap_loaders');
3+
const { internalBinding } = require('internal/bootstrap/loaders');
44
const { ModuleWrap } = internalBinding('module_wrap');
55
const { SafeSet, SafePromise } = require('internal/safe_globals');
66
const assert = require('assert');

lib/internal/loader/ModuleRequest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const internalCJSModule = require('internal/module');
55
const CJSModule = require('module');
66
const internalURLModule = require('internal/url');
77
const internalFS = require('internal/fs');
8-
const { NativeModule } = require('internal/bootstrap_loaders');
8+
const { NativeModule } = require('internal/bootstrap/loaders');
99
const { extname, _makeLong } = require('path');
1010
const { URL } = require('url');
1111
const { realpathSync } = require('fs');

lib/internal/loader/ModuleWrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { internalBinding } = require('internal/bootstrap_loaders');
3+
const { internalBinding } = require('internal/bootstrap/loaders');
44
const {
55
ModuleWrap,
66
setImportModuleDynamicallyCallback

lib/internal/loader/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const { URL } = require('url');
44
const CJSmodule = require('module');
55
const errors = require('internal/errors');
6-
const { internalBinding } = require('internal/bootstrap_loaders');
6+
const { internalBinding } = require('internal/bootstrap/loaders');
77
const { resolve } = internalBinding('module_wrap');
88

99
module.exports = (target, base) => {

lib/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
'use strict';
2323

24-
const { NativeModule } = require('internal/bootstrap_loaders');
24+
const { NativeModule } = require('internal/bootstrap/loaders');
2525
const util = require('util');
2626
const internalModule = require('internal/module');
2727
const { getURLFromFilePath } = require('internal/url');

node.gyp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
'node_lib_target_name%': 'node_lib',
2626
'node_intermediate_lib_type%': 'static_library',
2727
'library_files': [
28-
'lib/internal/bootstrap_loaders.js',
29-
'lib/internal/bootstrap_node.js',
28+
'lib/internal/bootstrap/loaders.js',
29+
'lib/internal/bootstrap/node.js',
3030
'lib/async_hooks.js',
3131
'lib/assert.js',
3232
'lib/buffer.js',

src/node.cc

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ bool config_experimental_modules = false;
240240

241241
// Set in node.cc by ParseArgs when --loader is used.
242242
// Used in node_config.cc to set a constant on process.binding('config')
243-
// that is used by lib/internal/bootstrap_node.js
243+
// that is used by lib/internal/bootstrap/node.js
244244
std::string config_userland_loader; // NOLINT(runtime/string)
245245

246246
// Set by ParseArgs when --pending-deprecation or NODE_PENDING_DEPRECATION
@@ -253,7 +253,7 @@ std::string config_warning_file; // NOLINT(runtime/string)
253253
// Set in node.cc by ParseArgs when --expose-internals or --expose_internals is
254254
// used.
255255
// Used in node_config.cc to set a constant on process.binding('config')
256-
// that is used by lib/internal/bootstrap_node.js
256+
// that is used by lib/internal/bootstrap/node.js
257257
bool config_expose_internals = false;
258258

259259
// Set to false in node.cc when NODE_NO_HTTP2=1 is used.
@@ -3685,23 +3685,23 @@ static Local<Function> GetBootstrapper(Environment* env, Local<String> source,
36853685
// are not safe to ignore.
36863686
try_catch.SetVerbose(false);
36873687

3688-
// Execute the factory javascript file
3689-
Local<Value> factory_v = ExecuteString(env, source, script_name);
3688+
// Execute the bootstrapper javascript file
3689+
Local<Value> bootstrapper_v = ExecuteString(env, source, script_name);
36903690
if (try_catch.HasCaught()) {
36913691
ReportException(env, try_catch);
36923692
exit(10);
36933693
}
36943694

3695-
CHECK(factory_v->IsFunction());
3696-
Local<Function> factory = Local<Function>::Cast(factory_v);
3695+
CHECK(bootstrapper_v->IsFunction());
3696+
Local<Function> bootstrapper = Local<Function>::Cast(bootstrapper_v);
36973697

3698-
return scope.Escape(factory);
3698+
return scope.Escape(bootstrapper);
36993699
}
37003700

3701-
static bool ExecuteBootstrapper(Environment* env, Local<Function> factory,
3701+
static bool ExecuteBootstrapper(Environment* env, Local<Function> bootstrapper,
37023702
int argc, Local<Value> argv[],
37033703
Local<Value>* out) {
3704-
bool ret = factory->Call(
3704+
bool ret = bootstrapper->Call(
37053705
env->context(), Null(env->isolate()), argc, argv).ToLocal(out);
37063706

37073707
// If there was an error during bootstrap then it was either handled by the
@@ -3728,16 +3728,18 @@ void LoadEnvironment(Environment* env) {
37283728
// are not safe to ignore.
37293729
try_catch.SetVerbose(false);
37303730

3731-
// The factory scripts are lib/internal/bootstrap_loaders.js and
3732-
// lib/internal/bootstrap_node.js, each included as a static C string
3731+
// The bootstrapper scripts are lib/internal/bootstrap/loaders.js and
3732+
// lib/internal/bootstrap/node.js, each included as a static C string
37333733
// defined in node_javascript.h, generated in node_javascript.cc by
37343734
// node_js2c.
3735+
Local<String> loaders_name =
3736+
FIXED_ONE_BYTE_STRING(env->isolate(), "internal/bootstrap/loaders.js");
37353737
Local<Function> loaders_bootstrapper =
3736-
GetBootstrapper(env, LoadersBootstrapperSource(env),
3737-
FIXED_ONE_BYTE_STRING(env->isolate(), "bootstrap_loaders.js"));
3738+
GetBootstrapper(env, LoadersBootstrapperSource(env), loaders_name);
3739+
Local<String> node_name =
3740+
FIXED_ONE_BYTE_STRING(env->isolate(), "internal/bootstrap/node.js");
37383741
Local<Function> node_bootstrapper =
3739-
GetBootstrapper(env, NodeBootstrapperSource(env),
3740-
FIXED_ONE_BYTE_STRING(env->isolate(), "bootstrap_node.js"));
3742+
GetBootstrapper(env, NodeBootstrapperSource(env), node_name);
37413743

37423744
// Add a reference to the global object
37433745
Local<Object> global = env->context()->Global();

src/node_internals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ extern bool config_experimental_modules;
158158

159159
// Set in node.cc by ParseArgs when --loader is used.
160160
// Used in node_config.cc to set a constant on process.binding('config')
161-
// that is used by lib/internal/bootstrap_node.js
161+
// that is used by lib/internal/bootstrap/node.js
162162
extern std::string config_userland_loader;
163163

164164
// Set in node.cc by ParseArgs when --expose-internals or --expose_internals is
165165
// used.
166166
// Used in node_config.cc to set a constant on process.binding('config')
167-
// that is used by lib/internal/bootstrap_node.js
167+
// that is used by lib/internal/bootstrap/node.js
168168
extern bool config_expose_internals;
169169

170170
// Set in node.cc by ParseArgs when --redirect-warnings= is used.

0 commit comments

Comments
 (0)