Skip to content

Commit 98a6db7

Browse files
committed
fix: only set import:false when re-build share entry
1 parent d5d7f5c commit 98a6db7

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

crates/rspack_plugin_mf/src/sharing/collect_share_entry_plugin.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,13 @@ async fn this_compilation(
323323

324324
#[plugin_hook(CompilationProcessAssets for CollectShareEntryPlugin)]
325325
async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
326-
dbg!("process_assets");
327326
// 遍历图中的 ConsumeSharedModule,收集其 fallback 映射到的真实模块地址
328327
let module_graph = compilation.get_module_graph();
329328
let mut ordered_requests: FxHashMap<String, Vec<[String; 2]>> = FxHashMap::default();
330329
let mut share_scopes: FxHashMap<String, String> = FxHashMap::default();
331330

332-
for (id, module) in module_graph.modules().into_iter() {
331+
for (_id, module) in module_graph.modules().into_iter() {
333332
let module_type = module.module_type();
334-
dbg!(&module_type);
335333
if !matches!(module_type, rspack_core::ModuleType::ConsumeShared) {
336334
continue;
337335
}
@@ -342,7 +340,6 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
342340
{
343341
// 从 readable_identifier 中解析 share_scope 与 share_key
344342
let ident = consume.readable_identifier(&Context::default()).to_string();
345-
dbg!(&ident);
346343
// 形如: "consume shared module ({scope}) {share_key}@..."
347344
let (scope, key) = {
348345
let mut scope = String::new();
@@ -360,11 +357,9 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
360357
}
361358
(scope, key)
362359
};
363-
364360
if key.is_empty() {
365361
continue;
366362
}
367-
368363
// 收集该 consume 模块的依赖与异步块中的依赖对应的真实模块
369364
let mut target_modules = Vec::new();
370365
for dep_id in consume.get_dependencies() {

packages/rspack/src/sharing/IndependentSharePlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ export class IndependentSharePlugin {
343343
)
344344
.map(([key, options]) => ({
345345
[key]: {
346-
import: extraOptions ? options.import : false,
346+
import: !extraOptions ? options.import : false,
347347
shareKey: options.shareKey || key,
348348
shareScope: options.shareScope,
349349
requiredVersion: options.requiredVersion,

0 commit comments

Comments
 (0)