diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-06-18 17:24:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-18 17:24:18 -0400 |
commit | cba212b9c63f80b73994cf6012c5db83b31eefc9 (patch) | |
tree | 1d0ed2fc73e22e0d31d185734aca6d610aadcac3 /ext/node/analyze.rs | |
parent | 7b5c5147631101dd57e42525eae245668f9ce6fd (diff) |
perf(node): ensure cjs wrapper module has deterministic output (#24248)
Diffstat (limited to 'ext/node/analyze.rs')
-rw-r--r-- | ext/node/analyze.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/node/analyze.rs b/ext/node/analyze.rs index 3b06a90e0..d80108733 100644 --- a/ext/node/analyze.rs +++ b/ext/node/analyze.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::collections::BTreeSet; use std::collections::HashSet; use std::path::Path; use std::path::PathBuf; @@ -106,7 +107,8 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> { .to_string(), ]; - let mut all_exports = analysis.exports.into_iter().collect::<HashSet<_>>(); + // use a BTreeSet to make the output deterministic for v8's code cache + let mut all_exports = analysis.exports.into_iter().collect::<BTreeSet<_>>(); if !analysis.reexports.is_empty() { let mut errors = Vec::new(); @@ -159,7 +161,7 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> { &'a self, entry_specifier: &url::Url, reexports: Vec<String>, - all_exports: &mut HashSet<String>, + all_exports: &mut BTreeSet<String>, // this goes through the modules concurrently, so collect // the errors in order to be deterministic errors: &mut Vec<anyhow::Error>, |