@@ -283,6 +283,18 @@ void IsExperimentalSeaWarningNeeded(const FunctionCallbackInfo<Value>& args) {
283283 sea_resource.flags & SeaFlags::kDisableExperimentalSeaWarning ));
284284}
285285
286+ void IsSeaDynamicImportFromFileSystemEnabled (
287+ const FunctionCallbackInfo<Value>& args) {
288+ if (!IsSingleExecutable ()) {
289+ args.GetReturnValue ().Set (false );
290+ return ;
291+ }
292+
293+ SeaResource sea_resource = FindSingleExecutableResource ();
294+ args.GetReturnValue ().Set (static_cast <bool >(
295+ sea_resource.flags & SeaFlags::kAllowDynamicImportFromFileSystem ));
296+ }
297+
286298std::tuple<int , char **> FixupArgsForSEA (int argc, char ** argv) {
287299 // Repeats argv[0] at position 1 on argv as a replacement for the missing
288300 // entry point file path.
@@ -444,6 +456,18 @@ std::optional<SeaConfig> ParseSingleExecutableConfig(
444456 if (use_code_cache_value) {
445457 result.flags |= SeaFlags::kUseCodeCache ;
446458 }
459+ } else if (key == " allowDynamicImportFromFileSystem" ) {
460+ bool allow_dynamic_import_from_file_system;
461+ if (field.value ().get_bool ().get (allow_dynamic_import_from_file_system)) {
462+ FPrintF (stderr,
463+ " \" allowDynamicImportFromFileSystem\" field of %s is not a "
464+ " Boolean\n " ,
465+ config_path);
466+ return std::nullopt ;
467+ }
468+ if (allow_dynamic_import_from_file_system) {
469+ result.flags |= SeaFlags::kAllowDynamicImportFromFileSystem ;
470+ }
447471 } else if (key == " assets" ) {
448472 simdjson::ondemand::object assets_object;
449473 if (field.value ().get_object ().get (assets_object)) {
@@ -918,13 +942,18 @@ void Initialize(Local<Object> target,
918942 target,
919943 " isExperimentalSeaWarningNeeded" ,
920944 IsExperimentalSeaWarningNeeded);
945+ SetMethod (context,
946+ target,
947+ " isSeaDynamicImportFromFileSystemEnabled" ,
948+ IsSeaDynamicImportFromFileSystemEnabled);
921949 SetMethod (context, target, " getAsset" , GetAsset);
922950 SetMethod (context, target, " getAssetKeys" , GetAssetKeys);
923951}
924952
925953void RegisterExternalReferences (ExternalReferenceRegistry* registry) {
926954 registry->Register (IsSea);
927955 registry->Register (IsExperimentalSeaWarningNeeded);
956+ registry->Register (IsSeaDynamicImportFromFileSystemEnabled);
928957 registry->Register (GetAsset);
929958 registry->Register (GetAssetKeys);
930959}
0 commit comments