@@ -259,25 +259,33 @@ Local<Context> NewContext(Isolate* isolate,
259259 True (isolate));
260260
261261 {
262- // Run lib/internal/bootstrap/ context.js
262+ // Run per- context JS files.
263263 Context::Scope context_scope (context);
264264
265- std::vector<Local<String>> parameters = {
266- FIXED_ONE_BYTE_STRING (isolate, " global" )};
267- Local<Value> arguments[] = {context->Global ()};
268- MaybeLocal<Function> maybe_fn =
269- per_process::native_module_loader.LookupAndCompile (
270- context, " internal/bootstrap/context" , ¶meters, nullptr );
271- if (maybe_fn.IsEmpty ()) {
272- return Local<Context>();
273- }
274- Local<Function> fn = maybe_fn.ToLocalChecked ();
275- MaybeLocal<Value> result =
276- fn->Call (context, Undefined (isolate), arraysize (arguments), arguments);
277- // Execution failed during context creation.
278- // TODO(joyeecheung): deprecate this signature and return a MaybeLocal.
279- if (result.IsEmpty ()) {
280- return Local<Context>();
265+ static const char * context_files[] = {
266+ " internal/per_context/setup" ,
267+ nullptr
268+ };
269+
270+ for (const char ** module = context_files; *module != nullptr ; module ++) {
271+ std::vector<Local<String>> parameters = {
272+ FIXED_ONE_BYTE_STRING (isolate, " global" )};
273+ Local<Value> arguments[] = {context->Global ()};
274+ MaybeLocal<Function> maybe_fn =
275+ per_process::native_module_loader.LookupAndCompile (
276+ context, *module , ¶meters, nullptr );
277+ if (maybe_fn.IsEmpty ()) {
278+ return Local<Context>();
279+ }
280+ Local<Function> fn = maybe_fn.ToLocalChecked ();
281+ MaybeLocal<Value> result =
282+ fn->Call (context, Undefined (isolate),
283+ arraysize (arguments), arguments);
284+ // Execution failed during context creation.
285+ // TODO(joyeecheung): deprecate this signature and return a MaybeLocal.
286+ if (result.IsEmpty ()) {
287+ return Local<Context>();
288+ }
281289 }
282290 }
283291
0 commit comments