Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compile): be more deterministic when compiling the same code in different directories #27395

Merged
merged 10 commits into from
Dec 19, 2024

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Dec 17, 2024

Additionaly, this no longer unnecessarily stores the source twice for file specifiers and fixes some sourcemap issues.

Closes #27284

@dsherret

This comment was marked as outdated.

@dsherret dsherret added ci-draft Run the CI on draft PRs. and removed ci-draft Run the CI on draft PRs. labels Dec 17, 2024
@dsherret dsherret marked this pull request as ready for review December 17, 2024 16:53
None
};
let mut source_maps = Vec::with_capacity(graph.specifiers_count());
// todo(dsherret): transpile in parallel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open an issue about it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll implement it sometime I'm in the code soon.

} else {
self.shared.source_maps.get(file_name)
}
// todo(https://github.com/denoland/deno_core/pull/1007): don't clone
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we release deno_core before landing this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to not wait.

Comment on lines +241 to +255
builder.append_le(
self
.data
.iter()
.map(|(_, data, maybe_transpiled)| {
1 + 4
+ (data.len() as u64)
+ 1
+ match maybe_transpiled {
Some(transpiled) => 4 + (transpiled.len() as u64),
None => 0,
}
})
.sum::<u64>(),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This serialization is now quite complex, I'm starting to feel we should add some unit tests for it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also have you considered using serde_bincode instead of hand rolling it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok. If there were any issues with it then the integration tests would fail.

I think this is more clear what's going on and allows for lazily deserializing certain parts.

@dsherret dsherret merged commit 074444a into denoland:main Dec 19, 2024
17 checks passed
@dsherret dsherret deleted the fix_compile_determinism_cwd branch December 19, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Working directory PWD affects hash of output binary of deno compile
2 participants