Skip to content

Commit

Permalink
Revert "feat(turbopack): Handle fragment in requests" (vercel/turbore…
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Apr 9, 2024
1 parent 0339a11 commit 30ebc69
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 241 deletions.
18 changes: 6 additions & 12 deletions crates/turbopack-cli/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,12 @@ async fn build_internal(
.cloned()
.map(|r| async move {
Ok(match &*r.await? {
EntryRequest::Relative(p) => Request::relative(
Value::new(p.clone().into()),
Default::default(),
Default::default(),
false,
),
EntryRequest::Module(m, p) => Request::module(
m.clone(),
Value::new(p.clone().into()),
Default::default(),
Default::default(),
),
EntryRequest::Relative(p) => {
Request::relative(Value::new(p.clone().into()), Default::default(), false)
}
EntryRequest::Module(m, p) => {
Request::module(m.clone(), Value::new(p.clone().into()), Default::default())
}
})
})
.try_join()
Expand Down
18 changes: 6 additions & 12 deletions crates/turbopack-cli/src/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,12 @@ async fn source(
let entry_requests = entry_requests
.iter()
.map(|r| match r {
EntryRequest::Relative(p) => Request::relative(
Value::new(p.clone().into()),
Default::default(),
Default::default(),
false,
),
EntryRequest::Module(m, p) => Request::module(
m.clone(),
Value::new(p.clone().into()),
Default::default(),
Default::default(),
),
EntryRequest::Relative(p) => {
Request::relative(Value::new(p.clone().into()), Default::default(), false)
}
EntryRequest::Module(m, p) => {
Request::module(m.clone(), Value::new(p.clone().into()), Default::default())
}
})
.collect();

Expand Down
41 changes: 6 additions & 35 deletions crates/turbopack-core/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,6 @@ async fn resolve_internal_inline(
path,
query,
force_in_lookup_dir,
fragment,
} => {
let mut results = Vec::new();
let matches = read_matches(
Expand All @@ -1564,7 +1563,6 @@ async fn resolve_internal_inline(
options_value,
options,
*query,
*fragment,
)
.await?,
);
Expand All @@ -1584,7 +1582,6 @@ async fn resolve_internal_inline(
path,
query,
force_in_lookup_dir,
fragment,
} => {
resolve_relative_request(
lookup_path,
Expand All @@ -1594,15 +1591,13 @@ async fn resolve_internal_inline(
path,
*query,
*force_in_lookup_dir,
*fragment,
)
.await?
}
Request::Module {
module,
path,
query,
fragment,
} => {
resolve_module_request(
lookup_path,
Expand All @@ -1612,18 +1607,13 @@ async fn resolve_internal_inline(
module,
path,
*query,
*fragment,
)
.await?
}
Request::ServerRelative {
path,
query,
fragment,
} => {
Request::ServerRelative { path, query } => {
let mut new_pat = path.clone();
new_pat.push_front(".".to_string().into());
let relative = Request::relative(Value::new(new_pat), *query, *fragment, true);
let relative = Request::relative(Value::new(new_pat), *query, true);

if !has_alias {
ResolvingIssue {
Expand All @@ -1650,11 +1640,7 @@ async fn resolve_internal_inline(
)
.await?
}
Request::Windows {
path: _,
query: _,
fragment: _,
} => {
Request::Windows { path: _, query: _ } => {
if !has_alias {
ResolvingIssue {
severity: IssueSeverity::Error.cell(),
Expand Down Expand Up @@ -1698,8 +1684,6 @@ async fn resolve_internal_inline(
Request::Uri {
protocol,
remainder,
query: _,
fragment: _,
} => {
let uri = format!("{}{}", protocol, remainder);
ResolveResult::primary_with_key(
Expand Down Expand Up @@ -1834,7 +1818,6 @@ async fn resolve_relative_request(
path_pattern: &Pattern,
query: Vc<String>,
force_in_lookup_dir: bool,
fragment: Vc<String>,
) -> Result<Vc<ResolveResult>> {
// Check alias field for aliases first
let lookup_path_ref = &*lookup_path.await?;
Expand All @@ -1849,7 +1832,6 @@ async fn resolve_relative_request(
Some(request)
},
query,
fragment,
)
.await?
{
Expand Down Expand Up @@ -1900,7 +1882,6 @@ async fn resolve_relative_request(
options_value,
options,
query,
fragment,
)
.await?,
);
Expand All @@ -1918,7 +1899,6 @@ async fn resolve_relative_request(
options_value,
options,
query,
fragment,
)
.await?,
);
Expand All @@ -1942,7 +1922,6 @@ async fn apply_in_package(
options_value: &ResolveOptions,
get_request: impl Fn(&FileSystemPath) -> Option<String>,
query: Vc<String>,
fragment: Vc<String>,
) -> Result<Option<Vc<ResolveResult>>> {
// Check alias field for module aliases first
for in_package in options_value.in_package.iter() {
Expand Down Expand Up @@ -2008,8 +1987,7 @@ async fn apply_in_package(
resolve_internal(
package_path,
Request::parse(Value::new(Pattern::Constant(value.to_string())))
.with_query(query)
.with_fragment(fragment),
.with_query(query),
options,
)
.with_replaced_request_key(value.to_string(), Value::new(request_key))
Expand Down Expand Up @@ -2045,7 +2023,6 @@ async fn resolve_module_request(
module: &str,
path: &Pattern,
query: Vc<String>,
fragment: Vc<String>,
) -> Result<Vc<ResolveResult>> {
// Check alias field for module aliases first
if let Some(result) = apply_in_package(
Expand All @@ -2057,7 +2034,6 @@ async fn resolve_module_request(
full_pattern.into_string()
},
query,
fragment,
)
.await?
{
Expand Down Expand Up @@ -2092,7 +2068,6 @@ async fn resolve_module_request(
Value::new(path.clone()),
package_path,
query,
fragment,
options,
));
}
Expand All @@ -2106,7 +2081,6 @@ async fn resolve_module_request(
options_value,
options,
query,
fragment,
)
.await?;
results.push(resolved)
Expand All @@ -2129,7 +2103,7 @@ async fn resolve_module_request(
"/".to_string().into(),
path.clone(),
]);
let relative = Request::relative(Value::new(pattern), query, fragment, true);
let relative = Request::relative(Value::new(pattern), query, true);
let relative_result =
resolve_internal_boxed(lookup_path, relative.resolve().await?, options).await?;
let relative_result = relative_result.with_replaced_request_key(
Expand All @@ -2148,7 +2122,6 @@ async fn resolve_into_package(
path: Value<Pattern>,
package_path: Vc<FileSystemPath>,
query: Vc<String>,
fragment: Vc<String>,
options: Vc<ResolveOptions>,
) -> Result<Vc<ResolveResult>> {
let path = path.into_value();
Expand Down Expand Up @@ -2213,7 +2186,7 @@ async fn resolve_into_package(
let mut new_pat = path.clone();
new_pat.push_front(".".to_string().into());

let relative = Request::relative(Value::new(new_pat), query, fragment, true);
let relative = Request::relative(Value::new(new_pat), query, true);
results
.push(resolve_internal_inline(package_path, relative.resolve().await?, options).await?);
}
Expand Down Expand Up @@ -2297,7 +2270,6 @@ async fn resolved(
options_value: &ResolveOptions,
options: Vc<ResolveOptions>,
query: Vc<String>,
fragment: Vc<String>,
) -> Result<Vc<ResolveResult>> {
let RealPathResult { path, symlinks } = &*fs_path.realpath_with_links().await?;

Expand All @@ -2309,7 +2281,6 @@ async fn resolved(
options_value,
|package_path| package_path.get_relative_path_to(path_ref),
query,
fragment,
)
.await?
{
Expand Down
Loading

0 comments on commit 30ebc69

Please sign in to comment.