Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions src/bundler/Chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use crate::bun_fs;
use crate::Graph::Graph;
#[cfg(debug_assertions)]
use crate::LinkerContext;
use crate::html_import_manifest as HTMLImportManifest;
use crate::options::{self, Loader};
use crate::{
AdditionalFile, CompileResult, LinkerGraph, PartRange, PathTemplate, cheap_prefix_normalizer,
Expand Down Expand Up @@ -778,15 +777,7 @@ impl IntermediateOutput {
}

QueryKind::HtmlImport => {
count += bun_core::fmt::count(format_args!(
"{}",
HTMLImportManifest::format_escaped_json(
piece.query.index(),
graph,
chunks,
linker_graph,
)
));
count += graph.html_imports.printed_manifest(index).len();
continue;
}
QueryKind::None | QueryKind::ChunkId => unreachable!(),
Expand Down Expand Up @@ -960,17 +951,9 @@ impl IntermediateOutput {
}

QueryKind::HtmlImport => {
let mut cursor: &mut [u8] = remain;
let before_len = cursor.len();
HTMLImportManifest::write_escaped_json(
piece.query.index(),
graph,
linker_graph,
chunks,
&mut cursor,
)
.expect("unreachable");
let written = before_len - cursor.len();
let manifest = graph.html_imports.printed_manifest(index);
let written = manifest.len();
remain[..written].copy_from_slice(manifest);

if ENABLE_SOURCE_MAP_SHIFTS {
// The placeholder was an HtmlImport unique key, which has
Expand Down
12 changes: 12 additions & 0 deletions src/bundler/Graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ pub struct HtmlImports {
pub(crate) server_source_indices: Vec<IndexInt>,
/// Source index of the HTML file being imported
pub(crate) html_source_indices: Vec<IndexInt>,
/// The manifest of each page that a chunk prints. Set once the chunks are named.
pub(crate) manifests: Vec<Option<crate::HTMLImportManifest::Manifest>>,
}

impl HtmlImports {
/// What a chunk prints for the page at `index`.
pub(crate) fn printed_manifest(&self, index: usize) -> &[u8] {
&self.manifests[index]
.as_ref()
.expect("a chunk is named before it is printed")
.escaped
}
}

pub struct InputFile<'a> {
Expand Down
Loading
Loading