Skip to content

Commit

Permalink
Merge branch 'main' into kdy1/swc-core-0-90-10
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Apr 9, 2024
2 parents 030510a + b611074 commit 438ca18
Show file tree
Hide file tree
Showing 25 changed files with 696 additions and 83 deletions.
18 changes: 12 additions & 6 deletions crates/turbopack-cli/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,18 @@ 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(), false)
}
EntryRequest::Module(m, p) => {
Request::module(m.clone(), Value::new(p.clone().into()), Default::default())
}
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(),
),
})
})
.try_join()
Expand Down
18 changes: 12 additions & 6 deletions crates/turbopack-cli/src/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,18 @@ 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(), false)
}
EntryRequest::Module(m, p) => {
Request::module(m.clone(), Value::new(p.clone().into()), Default::default())
}
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(),
),
})
.collect();

Expand Down
4 changes: 3 additions & 1 deletion crates/turbopack-core/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ impl Environment {
Vc::cell(vec!["node".to_string()])
}
ExecutionEnvironment::Browser(_) => Vc::<Vec<String>>::default(),
ExecutionEnvironment::EdgeWorker(_) => Vc::cell(vec!["edge-worker".to_string()]),
ExecutionEnvironment::EdgeWorker(_) => {
Vc::cell(vec!["edge-light".to_string(), "worker".to_string()])
}
ExecutionEnvironment::Custom(_) => todo!(),
})
}
Expand Down
41 changes: 35 additions & 6 deletions crates/turbopack-core/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,7 @@ async fn resolve_internal_inline(
path,
query,
force_in_lookup_dir,
fragment,
} => {
let mut results = Vec::new();
let matches = read_matches(
Expand All @@ -1563,6 +1564,7 @@ async fn resolve_internal_inline(
options_value,
options,
*query,
*fragment,
)
.await?,
);
Expand All @@ -1582,6 +1584,7 @@ async fn resolve_internal_inline(
path,
query,
force_in_lookup_dir,
fragment,
} => {
resolve_relative_request(
lookup_path,
Expand All @@ -1591,13 +1594,15 @@ 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 @@ -1607,13 +1612,18 @@ async fn resolve_internal_inline(
module,
path,
*query,
*fragment,
)
.await?
}
Request::ServerRelative { path, query } => {
Request::ServerRelative {
path,
query,
fragment,
} => {
let mut new_pat = path.clone();
new_pat.push_front(".".to_string().into());
let relative = Request::relative(Value::new(new_pat), *query, true);
let relative = Request::relative(Value::new(new_pat), *query, *fragment, true);

if !has_alias {
ResolvingIssue {
Expand All @@ -1640,7 +1650,11 @@ async fn resolve_internal_inline(
)
.await?
}
Request::Windows { path: _, query: _ } => {
Request::Windows {
path: _,
query: _,
fragment: _,
} => {
if !has_alias {
ResolvingIssue {
severity: IssueSeverity::Error.cell(),
Expand Down Expand Up @@ -1684,6 +1698,8 @@ async fn resolve_internal_inline(
Request::Uri {
protocol,
remainder,
query: _,
fragment: _,
} => {
let uri = format!("{}{}", protocol, remainder);
ResolveResult::primary_with_key(
Expand Down Expand Up @@ -1818,6 +1834,7 @@ 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 @@ -1832,6 +1849,7 @@ async fn resolve_relative_request(
Some(request)
},
query,
fragment,
)
.await?
{
Expand Down Expand Up @@ -1882,6 +1900,7 @@ async fn resolve_relative_request(
options_value,
options,
query,
fragment,
)
.await?,
);
Expand All @@ -1899,6 +1918,7 @@ async fn resolve_relative_request(
options_value,
options,
query,
fragment,
)
.await?,
);
Expand All @@ -1922,6 +1942,7 @@ 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 @@ -1987,7 +2008,8 @@ async fn apply_in_package(
resolve_internal(
package_path,
Request::parse(Value::new(Pattern::Constant(value.to_string())))
.with_query(query),
.with_query(query)
.with_fragment(fragment),
options,
)
.with_replaced_request_key(value.to_string(), Value::new(request_key))
Expand Down Expand Up @@ -2023,6 +2045,7 @@ 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 @@ -2034,6 +2057,7 @@ async fn resolve_module_request(
full_pattern.into_string()
},
query,
fragment,
)
.await?
{
Expand Down Expand Up @@ -2068,6 +2092,7 @@ async fn resolve_module_request(
Value::new(path.clone()),
package_path,
query,
fragment,
options,
));
}
Expand All @@ -2081,6 +2106,7 @@ async fn resolve_module_request(
options_value,
options,
query,
fragment,
)
.await?;
results.push(resolved)
Expand All @@ -2103,7 +2129,7 @@ async fn resolve_module_request(
"/".to_string().into(),
path.clone(),
]);
let relative = Request::relative(Value::new(pattern), query, true);
let relative = Request::relative(Value::new(pattern), query, fragment, 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 @@ -2122,6 +2148,7 @@ 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 @@ -2186,7 +2213,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, true);
let relative = Request::relative(Value::new(new_pat), query, fragment, true);
results
.push(resolve_internal_inline(package_path, relative.resolve().await?, options).await?);
}
Expand Down Expand Up @@ -2270,6 +2297,7 @@ 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 @@ -2281,6 +2309,7 @@ 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 438ca18

Please sign in to comment.