From baf20e4e91e2e6592ac3ed67913349d9d3688308 Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Thu, 5 Dec 2024 12:46:29 +0800 Subject: [PATCH] fix: module info system --- crates/mako/src/build.rs | 1 + .../src/plugins/tree_shaking/shake/find_export_source.rs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/mako/src/build.rs b/crates/mako/src/build.rs index c1b0fbc8e..7c66dd0e7 100644 --- a/crates/mako/src/build.rs +++ b/crates/mako/src/build.rs @@ -235,6 +235,7 @@ __mako_require__.loadScript('{}', (e) => e.type === 'load' ? resolve() : reject( ModuleInfo { file, + module_system: get_module_system(&ast), ast, is_ignored: true, ..Default::default() diff --git a/crates/mako/src/plugins/tree_shaking/shake/find_export_source.rs b/crates/mako/src/plugins/tree_shaking/shake/find_export_source.rs index 66913341f..030a92e10 100644 --- a/crates/mako/src/plugins/tree_shaking/shake/find_export_source.rs +++ b/crates/mako/src/plugins/tree_shaking/shake/find_export_source.rs @@ -189,6 +189,7 @@ mod tests { use super::TreeShakeModule; use crate::ast::file::{Content, File, JsContent}; use crate::ast::js_ast::JsAst; + use crate::ast::utils::get_module_system; use crate::compiler::Context; use crate::module::{Module, ModuleAst, ModuleInfo}; use crate::plugins::tree_shaking::shake::skip_module::ReExportSource; @@ -465,13 +466,13 @@ mod tests { }), context.clone(), ); - let ast = JsAst::new(&file, context.clone()).unwrap(); - + let ast = ModuleAst::Script(JsAst::new(&file, context.clone()).unwrap()); let mako_module = Module { id: "test.js".into(), is_entry: false, info: Some(ModuleInfo { - ast: ModuleAst::Script(ast), + module_system: get_module_system(&ast), + ast, file, ..Default::default() }),