Unverified Commit b7d4e14a authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

refactor(turbopack-dev-server): Use ResolvedVc/NonLocalValue in RewriteType,…

refactor(turbopack-dev-server): Use ResolvedVc/NonLocalValue in RewriteType, remove all "local" opt-outs from structs (#74708)
parent 5c4294fe
...@@ -475,33 +475,31 @@ impl ContentSource for NoContentSource { ...@@ -475,33 +475,31 @@ impl ContentSource for NoContentSource {
} }
} }
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, NonLocalValue)]
pub enum RewriteType { pub enum RewriteType {
Location { Location {
/// The new path and query used to lookup content. This _does not_ need /// The new path and query used to lookup content. This _does not_ need to be the original
/// to be the original path or query. /// path or query.
path_and_query: RcStr, path_and_query: RcStr,
}, },
ContentSource { ContentSource {
/// [Vc<Box<dyn ContentSource>>]s from which to restart the lookup /// [`ContentSource`]s from which to restart the lookup process. This _does not_ need to be
/// process. This _does not_ need to be the original content /// the original content source.
/// source. source: ResolvedVc<Box<dyn ContentSource>>,
source: Vc<Box<dyn ContentSource>>,
/// The new path and query used to lookup content. This _does not_ need /// The new path and query used to lookup content. This _does not_ need
/// to be the original path or query. /// to be the original path or query.
path_and_query: RcStr, path_and_query: RcStr,
}, },
Sources { Sources {
/// [GetContentSourceContent]s from which to restart the lookup /// [`GetContentSourceContent`]s from which to restart the lookup process. This _does not_
/// process. This _does not_ need to be the original content /// need to be the original content source.
/// source. sources: ResolvedVc<GetContentSourceContents>,
sources: Vc<GetContentSourceContents>,
}, },
} }
/// A rewrite returned from a [ContentSource]. This tells the dev server to /// A rewrite returned from a [ContentSource]. This tells the dev server to
/// update its parsed url, path, and queries with this new information. /// update its parsed url, path, and queries with this new information.
#[turbo_tasks::value(shared, local)] #[turbo_tasks::value(shared)]
#[derive(Debug)] #[derive(Debug)]
pub struct Rewrite { pub struct Rewrite {
pub ty: RewriteType, pub ty: RewriteType,
...@@ -531,7 +529,7 @@ impl RewriteBuilder { ...@@ -531,7 +529,7 @@ impl RewriteBuilder {
} }
pub fn new_source_with_path_and_query( pub fn new_source_with_path_and_query(
source: Vc<Box<dyn ContentSource>>, source: ResolvedVc<Box<dyn ContentSource>>,
path_and_query: RcStr, path_and_query: RcStr,
) -> Self { ) -> Self {
Self { Self {
...@@ -546,7 +544,7 @@ impl RewriteBuilder { ...@@ -546,7 +544,7 @@ impl RewriteBuilder {
} }
} }
pub fn new_sources(sources: Vc<GetContentSourceContents>) -> Self { pub fn new_sources(sources: ResolvedVc<GetContentSourceContents>) -> Self {
Self { Self {
rewrite: Rewrite { rewrite: Rewrite {
ty: RewriteType::Sources { sources }, ty: RewriteType::Sources { sources },
......
...@@ -22,7 +22,7 @@ use super::{ ...@@ -22,7 +22,7 @@ use super::{
/// The result of [`resolve_source_request`]. Similar to a /// The result of [`resolve_source_request`]. Similar to a
/// `ContentSourceContent`, but without the `Rewrite` variant as this is taken /// `ContentSourceContent`, but without the `Rewrite` variant as this is taken
/// care in the function. /// care in the function.
#[turbo_tasks::value(serialization = "none", local)] #[turbo_tasks::value(serialization = "none")]
pub enum ResolveSourceRequestResult { pub enum ResolveSourceRequestResult {
NotFound, NotFound,
Static(ResolvedVc<StaticContent>, ResolvedVc<HeaderList>), Static(ResolvedVc<StaticContent>, ResolvedVc<HeaderList>),
...@@ -102,7 +102,7 @@ pub async fn resolve_source_request( ...@@ -102,7 +102,7 @@ pub async fn resolve_source_request(
RewriteType::Sources { RewriteType::Sources {
sources: new_sources, sources: new_sources,
} => { } => {
sources = *new_sources; sources = **new_sources;
continue 'sources; continue 'sources;
} }
} }
......
...@@ -63,7 +63,7 @@ impl GetContentSourceContent for WrappedGetContentSourceContent { ...@@ -63,7 +63,7 @@ impl GetContentSourceContent for WrappedGetContentSourceContent {
"Rewrites for WrappedGetContentSourceContent are not implemented yet" "Rewrites for WrappedGetContentSourceContent are not implemented yet"
), ),
RewriteType::Sources { sources } => RewriteType::Sources { RewriteType::Sources { sources } => RewriteType::Sources {
sources: Vc::cell( sources: ResolvedVc::cell(
sources sources
.await? .await?
.iter() .iter()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment