From cba212b9c63f80b73994cf6012c5db83b31eefc9 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 18 Jun 2024 17:24:18 -0400 Subject: perf(node): ensure cjs wrapper module has deterministic output (#24248) --- ext/node/analyze.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext') 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 NodeCodeTranslator { .to_string(), ]; - let mut all_exports = analysis.exports.into_iter().collect::>(); + // use a BTreeSet to make the output deterministic for v8's code cache + let mut all_exports = analysis.exports.into_iter().collect::>(); if !analysis.reexports.is_empty() { let mut errors = Vec::new(); @@ -159,7 +161,7 @@ impl NodeCodeTranslator { &'a self, entry_specifier: &url::Url, reexports: Vec, - all_exports: &mut HashSet, + all_exports: &mut BTreeSet, // this goes through the modules concurrently, so collect // the errors in order to be deterministic errors: &mut Vec, -- cgit v1.2.3