Skip to content

Commit

Permalink
Turbopack: refactor how EsmAssetReferences are added (#76011)
Browse files Browse the repository at this point in the history
A refactor to use less `Box<dyn ModuleReference>`

The snapshots changed because this changes the order of references to the internal parts (they are now in order as opposed to arbitrary order)

The next PR will be the one leverage this to remove `CodeGenerateable` from `EsmAssetReference`
  • Loading branch information
mischnic authored and devjiwonchoi committed Feb 14, 2025
1 parent 8d03bbb commit 91ccf20
Show file tree
Hide file tree
Showing 25 changed files with 387 additions and 377 deletions.
4 changes: 2 additions & 2 deletions turbopack/crates/turbopack-ecmascript/src/analyzer/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ impl ImportMap {
None
}

pub fn references(&self) -> impl Iterator<Item = &ImportMapReference> {
pub fn references(&self) -> impl ExactSizeIterator<Item = &ImportMapReference> {
self.references.iter()
}

pub fn reexports(&self) -> impl Iterator<Item = (usize, &Reexport)> {
pub fn reexports(&self) -> impl ExactSizeIterator<Item = (usize, &Reexport)> {
self.reexports.iter().map(|(i, r)| (*i, r))
}

Expand Down
224 changes: 117 additions & 107 deletions turbopack/crates/turbopack-ecmascript/src/references/mod.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var { g: global, d: __dirname } = __turbopack_context__;
{
__turbopack_context__.v((parentImport) => {
return Promise.all([
"output/b1abf_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_4f08a3.js"
"output/b1abf_turbopack-tests_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_8debd8.js"
].map((chunk) => __turbopack_context__.l(chunk))).then(() => {
return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript)");
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 91ccf20

Please sign in to comment.