Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(base): checking more strictly whether source map inlining is possible #458

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stamp: support specifying from the user context whether the source ma…
…p is applied
  • Loading branch information
nyannyacha committed Dec 9, 2024
commit 716bd884b4a464dce3766679ccc32bb0b964769e
25 changes: 14 additions & 11 deletions crates/base/src/deno_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ where
let is_user_worker = conf.is_user_worker();
let is_some_entry_point = maybe_entrypoint.is_some();

let maybe_user_conf = conf.as_user_worker();
let user_context = maybe_user_conf
.and_then(|it| it.context.clone())
.unwrap_or_default();

if is_some_entry_point {
main_module_url = Url::parse(&maybe_entrypoint.unwrap())?;
}
Expand All @@ -386,7 +391,7 @@ where
let mut allow_remote_modules = true;

if is_user_worker {
let user_conf = conf.as_user_worker().unwrap();
let user_conf = maybe_user_conf.unwrap();

net_access_disabled = user_conf.net_access_disabled;
allow_remote_modules = user_conf.allow_remote_modules;
Expand Down Expand Up @@ -514,12 +519,17 @@ where
}

let has_inspector = maybe_inspector.is_some();
let need_source_map = user_context
.get("sourceMap")
.and_then(serde_json::Value::as_bool)
.unwrap_or_default();

let rt_provider = create_module_loader_for_standalone_from_eszip_kind(
eszip,
base_dir_path.clone(),
maybe_import_map,
import_map_path,
has_inspector,
has_inspector || need_source_map,
)
.await?;

Expand Down Expand Up @@ -645,7 +655,7 @@ where
let beforeunload_mem_threshold = ArcSwapOption::<u64>::from_pointee(None);

if conf.is_user_worker() {
let conf = conf.as_user_worker().unwrap();
let conf = maybe_user_conf.unwrap();
let memory_limit_bytes = mib_to_bytes(conf.memory_limit_mb) as usize;

beforeunload_mem_threshold.store(
Expand Down Expand Up @@ -792,14 +802,7 @@ where
let extra_context = {
let mut context = serde_json::json!(RuntimeContext::get_extra_context());

json::merge_object(
&mut context,
&conf
.as_user_worker()
.and_then(|it| it.context.clone())
.map(serde_json::Value::Object)
.unwrap_or_else(|| serde_json::json!({})),
);
json::merge_object(&mut context, &serde_json::Value::Object(user_context));

context
};
Expand Down