@@ -289,25 +289,33 @@ Local<Context> NewContext(Isolate* isolate,
289
289
True (isolate));
290
290
291
291
{
292
- // Run lib/internal/bootstrap/ context.js
292
+ // Run per- context JS files.
293
293
Context::Scope context_scope (context);
294
294
295
- std::vector<Local<String>> parameters = {
296
- FIXED_ONE_BYTE_STRING (isolate, " global" )};
297
- Local<Value> arguments[] = {context->Global ()};
298
- MaybeLocal<Function> maybe_fn =
299
- per_process::native_module_loader.LookupAndCompile (
300
- context, " internal/bootstrap/context" , ¶meters, nullptr );
301
- if (maybe_fn.IsEmpty ()) {
302
- return Local<Context>();
303
- }
304
- Local<Function> fn = maybe_fn.ToLocalChecked ();
305
- MaybeLocal<Value> result =
306
- fn->Call (context, Undefined (isolate), arraysize (arguments), arguments);
307
- // Execution failed during context creation.
308
- // TODO(joyeecheung): deprecate this signature and return a MaybeLocal.
309
- if (result.IsEmpty ()) {
310
- return Local<Context>();
295
+ static const char * context_files[] = {
296
+ " internal/per_context/setup" ,
297
+ nullptr
298
+ };
299
+
300
+ for (const char ** module = context_files; *module != nullptr ; module++) {
301
+ std::vector<Local<String>> parameters = {
302
+ FIXED_ONE_BYTE_STRING (isolate, " global" )};
303
+ Local<Value> arguments[] = {context->Global ()};
304
+ MaybeLocal<Function> maybe_fn =
305
+ per_process::native_module_loader.LookupAndCompile (
306
+ context, *module, ¶meters, nullptr );
307
+ if (maybe_fn.IsEmpty ()) {
308
+ return Local<Context>();
309
+ }
310
+ Local<Function> fn = maybe_fn.ToLocalChecked ();
311
+ MaybeLocal<Value> result =
312
+ fn->Call (context, Undefined (isolate),
313
+ arraysize (arguments), arguments);
314
+ // Execution failed during context creation.
315
+ // TODO(joyeecheung): deprecate this signature and return a MaybeLocal.
316
+ if (result.IsEmpty ()) {
317
+ return Local<Context>();
318
+ }
311
319
}
312
320
}
313
321
0 commit comments