fix(node): support re-exported esm modules in cjs export analysis (#28379)

Adds support for re-exporting an ES module from a CJS one and then
importing the CJS module from ESM. Also fixes a bug where require esm
wasn't working in deno compile.
This commit is contained in:
David Sherret 2025-03-05 16:37:46 -05:00 committed by GitHub
parent 0c0757fe66
commit 2292eb1c92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 366 additions and 166 deletions

6
cli/cache/node.rs vendored
View file

@ -137,6 +137,8 @@ impl NodeAnalysisCacheInner {
#[cfg(test)]
mod test {
use deno_ast::ModuleExportsAndReExports;
use super::*;
#[test]
@ -148,10 +150,10 @@ mod test {
.get_cjs_analysis("file.js", CacheDBHash::new(2))
.unwrap()
.is_none());
let cjs_analysis = CliCjsAnalysis::Cjs {
let cjs_analysis = CliCjsAnalysis::Cjs(ModuleExportsAndReExports {
exports: vec!["export1".to_string()],
reexports: vec!["re-export1".to_string()],
};
});
cache
.set_cjs_analysis("file.js", CacheDBHash::new(2), &cjs_analysis)
.unwrap();