mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor: NodeCodeTranslator - optional source to translate_cjs_to_esm (#20000)
This commit is contained in:
parent
6b74a6f0b6
commit
99daad0541
2 changed files with 3 additions and 5 deletions
|
@ -782,7 +782,7 @@ impl NpmModuleLoader {
|
|||
// translate cjs to esm if it's cjs and inject node globals
|
||||
self.node_code_translator.translate_cjs_to_esm(
|
||||
specifier,
|
||||
&code,
|
||||
Some(code.as_str()),
|
||||
permissions,
|
||||
)?
|
||||
} else {
|
||||
|
|
|
@ -72,15 +72,13 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> {
|
|||
pub fn translate_cjs_to_esm(
|
||||
&self,
|
||||
specifier: &ModuleSpecifier,
|
||||
source: &str,
|
||||
source: Option<&str>,
|
||||
permissions: &dyn NodePermissions,
|
||||
) -> Result<String, AnyError> {
|
||||
let mut temp_var_count = 0;
|
||||
let mut handled_reexports: HashSet<String> = HashSet::default();
|
||||
|
||||
let analysis = self
|
||||
.cjs_code_analyzer
|
||||
.analyze_cjs(specifier, Some(source))?;
|
||||
let analysis = self.cjs_code_analyzer.analyze_cjs(specifier, source)?;
|
||||
|
||||
let mut source = vec![
|
||||
r#"import {createRequire as __internalCreateRequire} from "node:module";
|
||||
|
|
Loading…
Reference in a new issue