summaryrefslogtreecommitdiff
path: root/cli/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/main.rs')
-rw-r--r--cli/main.rs35
1 files changed, 27 insertions, 8 deletions
diff --git a/cli/main.rs b/cli/main.rs
index f4d4046df..67b59a443 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -204,6 +204,32 @@ pub fn create_main_worker(
let create_web_worker_cb = create_web_worker_callback(ps.clone());
+ let maybe_storage_key = if let Some(location) = &ps.flags.location {
+ // if a location is set, then the ascii serialization of the location is
+ // used, unless the origin is opaque, and then no storage origin is set, as
+ // we can't expect the origin to be reproducible
+ let storage_origin = location.origin().ascii_serialization();
+ if storage_origin == "null" {
+ None
+ } else {
+ Some(storage_origin)
+ }
+ } else if let Some(config_file) = &ps.maybe_config_file {
+ // otherwise we will use the path to the config file
+ config_file.path.to_str().map(|s| s.to_string())
+ } else {
+ // otherwise we will use the path to the main module
+ Some(main_module.to_string())
+ };
+
+ let origin_storage_dir = maybe_storage_key.map(|key| {
+ ps.dir
+ .root
+ // TODO(@crowlKats): change to origin_data for 2.0
+ .join("location_data")
+ .join(checksum::gen(&[key.as_bytes()]))
+ });
+
let options = WorkerOptions {
bootstrap: BootstrapOptions {
apply_source_maps: true,
@@ -231,14 +257,7 @@ pub fn create_main_worker(
should_break_on_first_statement,
module_loader,
get_error_class_fn: Some(&crate::errors::get_error_class_name),
- origin_storage_dir: ps.flags.location.clone().map(|loc| {
- ps.dir
- .root
- .clone()
- // TODO(@crowlKats): change to origin_data for 2.0
- .join("location_data")
- .join(checksum::gen(&[loc.to_string().as_bytes()]))
- }),
+ origin_storage_dir,
blob_store: ps.blob_store.clone(),
broadcast_channel: ps.broadcast_channel.clone(),
shared_array_buffer_store: Some(ps.shared_array_buffer_store.clone()),