diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-02-20 01:11:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-20 01:11:56 +0100 |
commit | a1cd2a5915c13f6a9b8eafa3807e143a02616bc1 (patch) | |
tree | f99a6983e790797abb143d333ca3551d0b414552 /core/modules.rs | |
parent | a01af067d79e78ea8e2c21cf0ef92d86d425f8eb (diff) |
refactor(core): definition of "ExtensionFileSource" (#17823)
This commit changes definition of "ExtensionFileSource", by changing
"code" field to being "ExtensionFileSourceCode" enum. Currently the enum
has only a single variant "IncludedInBinary". It is done in preparation
to allow embedders to decide if they want to include the source code in the
binary when snapshotting (in most cases they shouldn't do that).
In the follow up commit we'll add more variants to
"ExtensionFileSourceCode".
"include_js_files_dir!" macro was removed in favor "include_js_files!"
macro which can now accept "dir" option.
Diffstat (limited to 'core/modules.rs')
-rw-r--r-- | core/modules.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/modules.rs b/core/modules.rs index 1f427508a..43dabf411 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -3,6 +3,7 @@ use crate::bindings; use crate::error::generic_error; use crate::extensions::ExtensionFileSource; +use crate::extensions::ExtensionFileSourceCode; use crate::module_specifier::ModuleSpecifier; use crate::resolve_import; use crate::resolve_url; @@ -402,7 +403,11 @@ impl ModuleLoader for InternalModuleLoader { let result = if let Some(load_callback) = &self.maybe_load_callback { load_callback(file_source) } else { - Ok(file_source.code.to_string()) + match file_source.code { + ExtensionFileSourceCode::IncludedInBinary(code) => { + Ok(code.to_string()) + } + } }; return async move { |