Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f0e987

Browse files
authored
feat: add output chunk isDynamicEntry (#373)
1 parent 4d44e56 commit 7f0e987

7 files changed

Lines changed: 16 additions & 9 deletions

File tree

crates/rolldown/src/bundler/bundle/output.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub struct OutputChunk {
1212
pub file_name: String,
1313
pub code: String,
1414
pub is_entry: bool,
15+
pub is_dynamic_entry: bool,
1516
pub facade_module_id: Option<String>,
1617
pub modules: FxHashMap<String, RenderedModule>,
1718
pub exports: Vec<String>,

crates/rolldown/src/bundler/stages/bundle_stage.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ impl<'a> BundleStage<'a> {
6464
file_name: c.file_name.clone().unwrap(),
6565
code: content,
6666
is_entry: matches!(&c.entry_point, Some(e) if e.kind == EntryPointKind::UserSpecified),
67+
is_dynamic_entry: matches!(&c.entry_point, Some(e) if e.kind == EntryPointKind::DynamicImport),
6768
facade_module_id: c.entry_point.as_ref().map(|entry_point| {
6869
self.link_output.modules[entry_point.module_id].expect_normal().pretty_path.to_string()
6970
}),

crates/rolldown/tests/common/case.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ impl Case {
9393
.flat_map(|asset| match asset {
9494
Output::Chunk(chunk) => {
9595
vec![Cow::Owned(format!(
96-
"- {}, is_entry {}, facade_module_id {:?}, exports {:?}",
97-
chunk.file_name, chunk.is_entry, chunk.facade_module_id, chunk.exports
96+
"- {}, is_entry {}, is_dynamic_entry {}, facade_module_id {:?}, exports {:?}",
97+
chunk.file_name,
98+
chunk.is_entry,
99+
chunk.is_dynamic_entry,
100+
chunk.facade_module_id,
101+
chunk.exports
98102
))]
99103
}
100104
Output::Asset(_) => vec![],

crates/rolldown/tests/fixtures/code_splitting/artifacts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import('./dynamic_js.mjs')
3232

3333
## Output Stats
3434

35-
- 3.mjs, is_entry false, facade_module_id None, exports []
36-
- dynamic_js.mjs, is_entry false, facade_module_id Some("dynamic.js"), exports []
37-
- main1.mjs, is_entry true, facade_module_id Some("main1.js"), exports []
38-
- main2.mjs, is_entry true, facade_module_id Some("main2.js"), exports []
35+
- 3.mjs, is_entry false, is_dynamic_entry false, facade_module_id None, exports []
36+
- dynamic_js.mjs, is_entry false, is_dynamic_entry true, facade_module_id Some("dynamic.js"), exports []
37+
- main1.mjs, is_entry true, is_dynamic_entry false, facade_module_id Some("main1.js"), exports []
38+
- main2.mjs, is_entry true, is_dynamic_entry false, facade_module_id Some("main2.js"), exports []

crates/rolldown_binding/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface OutputChunk {
5454
code: string
5555
fileName: string
5656
isEntry: boolean
57+
isDynamicEntry: boolean
5758
facadeModuleId?: string
5859
modules: Record<string, RenderedModule>
5960
exports: Array<string>

crates/rolldown_binding/src/output.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct OutputChunk {
3737
pub code: String,
3838
pub file_name: String,
3939
pub is_entry: bool,
40+
pub is_dynamic_entry: bool,
4041
pub facade_module_id: Option<String>,
4142
pub modules: HashMap<String, RenderedModule>,
4243
pub exports: Vec<String>,
@@ -48,6 +49,7 @@ impl From<Box<rolldown::OutputChunk>> for OutputChunk {
4849
code: chunk.code,
4950
file_name: chunk.file_name,
5051
is_entry: chunk.is_entry,
52+
is_dynamic_entry: chunk.is_dynamic_entry,
5153
facade_module_id: chunk.facade_module_id,
5254
modules: chunk.modules.into_iter().map(|(key, value)| (key, value.into())).collect(),
5355
exports: chunk.exports,

packages/node/src/utils/transform-to-rollup-output.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function transformToRollupOutputChunk(chunk: OutputChunk): RollupOutputChunk {
1515
exports: chunk.exports,
1616
isEntry: chunk.isEntry,
1717
facadeModuleId: chunk.facadeModuleId || null,
18+
isDynamicEntry: chunk.isDynamicEntry,
1819
get dynamicImports() {
1920
return unimplemented()
2021
},
@@ -33,9 +34,6 @@ function transformToRollupOutputChunk(chunk: OutputChunk): RollupOutputChunk {
3334
get map() {
3435
return unimplemented()
3536
},
36-
get isDynamicEntry() {
37-
return unimplemented()
38-
},
3937
get isImplicitEntry() {
4038
return unimplemented()
4139
},

0 commit comments

Comments
 (0)