Skip to content

Commit 749a6de

Browse files
committed
Manually clean up LLM output
1 parent 43c89db commit 749a6de

File tree

13 files changed

+37
-44
lines changed

13 files changed

+37
-44
lines changed

turbopack/crates/turbopack-css/src/chunk/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl OutputAsset for CssChunk {
286286
} else {
287287
*ServerFileSystem::new().root().to_resolved().await?
288288
},
289-
query: *Vc::<RcStr>::default().to_resolved().await?,
289+
query: Vc::<RcStr>::default(),
290290
fragment: None,
291291
assets,
292292
modifiers: Vec::new(),

turbopack/crates/turbopack-dev-server/src/source/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub async fn resolve_source_request(
107107
}
108108
ContentSourceContent::Static(static_content) => {
109109
return Ok(ResolveSourceRequestResult::Static(
110-
static_content.to_resolved().await?,
110+
*static_content,
111111
HeaderList::new(response_header_overwrites)
112112
.to_resolved()
113113
.await?,

turbopack/crates/turbopack-dev-server/src/source/route_tree.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl RouteTree {
334334
match selector_segment {
335335
BaseSegment::Static(value) => Ok(RouteTree {
336336
base,
337-
static_segments: fxindexmap! { value => *inner.resolved_cell() },
337+
static_segments: fxindexmap! { value => inner.cell() },
338338
..Default::default()
339339
}
340340
.cell()),
@@ -380,9 +380,8 @@ impl RouteTree {
380380
for s in not_found_sources.iter_mut() {
381381
*s = mapper.map_get_content(*s);
382382
}
383-
384383
for r in static_segments.values_mut() {
385-
*r = *r.map_routes(mapper).to_resolved().await?;
384+
*r = r.map_routes(mapper);
386385
}
387386
for r in dynamic_segments.iter_mut() {
388387
*r = r.map_routes(mapper).to_resolved().await?;

turbopack/crates/turbopack-ecmascript/src/chunk_group_files_asset.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,22 @@ impl ChunkGroupFilesChunkItem {
126126
async fn chunks(&self) -> Result<Vc<OutputAssets>> {
127127
let inner = self.inner.await?;
128128
let chunks = if let Some(ecma) =
129-
ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(inner.module.to_resolved().await?)
130-
.await?
129+
Vc::try_resolve_sidecast::<Box<dyn EvaluatableAsset>>(inner.module).await?
131130
{
132-
let empty_assets = EvaluatableAssets::empty().to_resolved().await?;
133131
inner.chunking_context.evaluated_chunk_group_assets(
134132
inner.module.ident(),
135133
inner
136134
.runtime_entries
137-
.unwrap_or_else(|| empty_assets)
138-
.with_entry(*ecma),
135+
.as_deref()
136+
.copied()
137+
.unwrap_or_else(EvaluatableAssets::empty)
138+
.with_entry(ecma),
139139
Value::new(AvailabilityInfo::Root),
140140
)
141141
} else {
142142
inner
143143
.chunking_context
144-
.root_chunk_group_assets(*ResolvedVc::upcast(inner.module.to_resolved().await?))
144+
.root_chunk_group_assets(Vc::upcast(inner.module))
145145
};
146146
Ok(chunks)
147147
}

turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ impl EsmExports {
458458
}
459459

460460
if export_info.has_dynamic_exports {
461-
dynamic_exports.push((**asset).to_resolved().await?);
461+
dynamic_exports.push(*asset);
462462
}
463463
}
464464

turbopack/crates/turbopack-ecmascript/src/references/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl AnalyzeEcmascriptModuleResultBuilder {
316316
for c in self.code_gens.iter_mut() {
317317
match c {
318318
CodeGen::CodeGenerateable(c) => {
319-
*c = *c.to_resolved().await?;
319+
*c = c.resolve().await?;
320320
}
321321
CodeGen::CodeGenerateableWithAsyncModuleInfo(c) => {
322322
*c = c.to_resolved().await?;

turbopack/crates/turbopack-ecmascript/src/references/require_context.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ impl DirList {
8383
DirectoryEntry::File(path) => {
8484
if let Some(relative_path) = root_val.get_relative_path_to(&*path.await?) {
8585
if regex.is_match(&relative_path) {
86-
list.insert(
87-
relative_path,
88-
DirListEntry::File(path.to_resolved().await?),
89-
);
86+
list.insert(relative_path, DirListEntry::File(*path));
9087
}
9188
}
9289
}
@@ -124,8 +121,7 @@ impl DirList {
124121
for (k, entry) in &*dir {
125122
match entry {
126123
DirListEntry::File(path) => {
127-
// Don't dereference the path, store it as a Vc
128-
list.insert(k.clone(), path.resolve().await?);
124+
list.insert(k.clone(), **path);
129125
}
130126
DirListEntry::Dir(d) => {
131127
queue.push_back(d.await?);

turbopack/crates/turbopack-node/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub async fn external_asset_entrypoints(
127127
/// assets.
128128
#[turbo_tasks::function]
129129
async fn separate_assets(
130-
intermediate_asset: Vc<Box<dyn OutputAsset>>,
130+
intermediate_asset: ResolvedVc<Box<dyn OutputAsset>>,
131131
intermediate_output_path: Vc<FileSystemPath>,
132132
) -> Result<Vc<SeparatedAssets>> {
133133
let intermediate_output_path = &*intermediate_output_path.await?;
@@ -166,10 +166,7 @@ async fn separate_assets(
166166

167167
let graph = AdjacencyMap::new()
168168
.skip_duplicates()
169-
.visit(
170-
once(Type::Internal(intermediate_asset.to_resolved().await?)),
171-
get_asset_children,
172-
)
169+
.visit(once(Type::Internal(intermediate_asset)), get_asset_children)
173170
.await
174171
.completed()?
175172
.into_inner();

turbopack/crates/turbopack-node/src/render/render_static.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ async fn render_stream_internal(
317317
RenderStaticIncomingMessage::Headers { data } => yield RenderItem::Headers(data),
318318
RenderStaticIncomingMessage::Rewrite { path } => {
319319
drop(guard);
320-
yield RenderItem::Response(StaticResult::rewrite(RewriteBuilder::new(path).build()).to_resolved().await?);
320+
yield RenderItem::Response(
321+
StaticResult::rewrite(RewriteBuilder::new(path).build()).to_resolved().await?
322+
);
321323
return;
322324
}
323325
RenderStaticIncomingMessage::Response {

turbopack/crates/turbopack-node/src/transforms/postcss.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -511,16 +511,9 @@ impl PostCssTransformedAsset {
511511

512512
// TODO handle SourceMap
513513
let file = File::from(processed_css.css);
514-
let mut resolved_assets = Vec::new();
515-
for asset in emitted_assets_to_virtual_sources(processed_css.assets) {
516-
resolved_assets.push(asset.to_resolved().await?);
517-
}
518-
let content = AssetContent::File(*FileContent::Content(file).resolved_cell()).cell();
519-
Ok(ProcessPostCssResult {
520-
content,
521-
assets: resolved_assets,
522-
}
523-
.cell())
514+
let assets = emitted_assets_to_virtual_sources(processed_css.assets).await?;
515+
let content = AssetContent::File(FileContent::Content(file).cell()).cell();
516+
Ok(ProcessPostCssResult { content, assets }.cell())
524517
}
525518
}
526519

0 commit comments

Comments
 (0)