Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
3aa8628
feat: add ConsumeShared module usage tracking to FlagDependencyUsageP…
ScriptedAlchemy Jun 19, 2025
c8893f3
feat: enhance ConsumeShared module export metadata copying
ScriptedAlchemy Jun 19, 2025
fe28840
fix: Group 1 incremental merge - foundation & infrastructure
ScriptedAlchemy Jul 6, 2025
84f603a
feat: add tree-shaking macro comments for ConsumeShared modules
ScriptedAlchemy Jun 19, 2025
b81fb94
docs: add additional analysis tools and research documentation
ScriptedAlchemy Jun 19, 2025
7e01eb3
fix: disable ConsumeShared tree-shaking macros temporarily for Group …
ScriptedAlchemy Jul 6, 2025
989aaa3
chore: remove research
ScriptedAlchemy Jun 19, 2025
cd5f1f5
fix: resolve borrow checker error in consume_shared_plugin.rs
ScriptedAlchemy Jun 20, 2025
9ca1f17
fix: resolve compilation errors in enhanced_share_usage_plugin.rs
ScriptedAlchemy Jun 20, 2025
ed79acb
feat: implement Module Federation tree-shaking infrastructure
ScriptedAlchemy Jul 7, 2025
fbb78e4
feat: implement Module Federation tree-shaking infrastructure
ScriptedAlchemy Jul 7, 2025
a0ba387
fix: correct typo in commit hash
ScriptedAlchemy Jul 7, 2025
039ea73
fix: resolve unused variable warning in common_js_exports_dependency
ScriptedAlchemy Jul 7, 2025
5a24ae1
fix: resolve remaining unused variable warnings
ScriptedAlchemy Jul 7, 2025
bd72c5f
fix: resolve dead code warnings
ScriptedAlchemy Jul 7, 2025
64dee65
feat: add tree-shaking macros for shared modules
ScriptedAlchemy Jul 7, 2025
ea6024d
fix: resolve clippy errors in tree-shaking macro implementation
ScriptedAlchemy Jul 7, 2025
2e41e22
fix: use shared_key instead of consume_shared_info for all shared mod…
ScriptedAlchemy Jul 7, 2025
6541b80
debug: add logging for ESMExportExpressionDependency fragment creation
ScriptedAlchemy Jul 7, 2025
0fb951d
fix: remove debug tracing and merge main branch
ScriptedAlchemy Jul 7, 2025
b3a71ff
fix: use actual shared keys instead of placeholder in CommonJS export…
ScriptedAlchemy Jul 7, 2025
51d6f08
feat: add tree-shaking macros to ConsumeShared fallback modules
ScriptedAlchemy Jul 7, 2025
0c0bc17
test: update test snapshots after tree-shaking macro implementation
ScriptedAlchemy Jul 7, 2025
171bf61
test: update expectations after tree-shaking macro implementation
ScriptedAlchemy Jul 7, 2025
153e025
fix: resolve Rust compilation warnings and clippy issues
ScriptedAlchemy Jul 7, 2025
6219c3a
feat: re-enable PURE annotations for shared module descendants
ScriptedAlchemy Jul 8, 2025
90dd176
test: update Module Federation tests to validate PURE annotations
ScriptedAlchemy Jul 8, 2025
6f6b809
docs: add problem statement for tree-shaking split chunks issue
ScriptedAlchemy Jul 9, 2025
6c1a705
x
ScriptedAlchemy Jul 9, 2025
9951b2b
feat: improve PURE annotation logic for shared modules
ScriptedAlchemy Jul 10, 2025
b73bf3f
fix: remove debug statement from runtime_template.rs
ScriptedAlchemy Jul 11, 2025
4b93b03
fix: merge main into swc-macro branch and resolve conflicts
ScriptedAlchemy Jul 14, 2025
018a099
Merge branch 'refs/heads/main' into swc-macro
ScriptedAlchemy Jul 14, 2025
3c38f6d
fix: correct batch to queue parameter references in flag_dependency_u…
ScriptedAlchemy Jul 14, 2025
c8b760d
fix: update pnpm-lock.yaml to match package.json dependencies
ScriptedAlchemy Jul 14, 2025
640ba7f
fix: exclude examples directory from biome linting
ScriptedAlchemy Jul 14, 2025
5876ed8
fix: remove [RT1] and [RT2] debug markers from runtime template
ScriptedAlchemy Jul 14, 2025
37a04a9
feat: implement Phase 1 of Module Federation shared detection optimiz…
ScriptedAlchemy Jul 15, 2025
91f78d0
feat: implement Phase 2 - extend optimization to CommonJS modules
ScriptedAlchemy Jul 15, 2025
4d37f4e
fix: preserve consume_shared_key for macro generation in Phase 2
ScriptedAlchemy Jul 15, 2025
7328948
fix: clean up temporary debug files and formatting
ScriptedAlchemy Jul 15, 2025
e5527ae
fix: update binding.d.ts to include new BuildMeta fields
ScriptedAlchemy Jul 15, 2025
5db5759
feat: enhance ShareUsagePlugin with entry module IDs and improve hook…
ScriptedAlchemy Jul 15, 2025
619b057
Merge origin/main into swc-macro
ScriptedAlchemy Jul 15, 2025
39c3016
chore: ignore examples/basic directory from biome linting
ScriptedAlchemy Jul 15, 2025
f4a2164
chore: remove documentation files not present on main branch
ScriptedAlchemy Jul 15, 2025
87a2712
feat: add Three.js Module Federation sharing benchmarks
ScriptedAlchemy Jul 15, 2025
425b06e
fix: add cspell ignore comments to shell scripts
ScriptedAlchemy Jul 15, 2025
232e57e
fix: resolve clippy warning for clone on Copy type
ScriptedAlchemy Jul 15, 2025
7e24834
fix: improve cspell configuration and remove build artifacts
ScriptedAlchemy Jul 16, 2025
a7d397c
chore: remove implementation-analysis directory
ScriptedAlchemy Jul 16, 2025
4b3beed
chore: remove redundant test files from basic example
ScriptedAlchemy Jul 16, 2025
3585b12
fix: add missing Three.js terms to cspell ignore
ScriptedAlchemy Jul 16, 2025
f0202c9
fix: resolve CI failures for spell check and rust check
ScriptedAlchemy Jul 16, 2025
41fe79f
fix: add technical terms to typos configuration
ScriptedAlchemy Jul 16, 2025
333087b
fix: resolve Rust clippy warnings
ScriptedAlchemy Jul 16, 2025
ed2f8a8
chore: clean up repository and consolidate tests
ScriptedAlchemy Jul 16, 2025
f2ff4e3
fix: remove redundant test function in consume_shared_plugin
ScriptedAlchemy Jul 16, 2025
1c96aa1
Merge branch 'main' into swc-macro
ScriptedAlchemy Jul 16, 2025
b58510c
perf: optimize is_consume_shared_descendant to use BuildMeta only
ScriptedAlchemy Jul 16, 2025
737f096
Merge branch 'main' into swc-macro - resolve conflicts by taking main…
ScriptedAlchemy Jul 16, 2025
c4a2e1d
feat: Add comprehensive tests for ShareUsagePlugin with strict module…
ScriptedAlchemy Jul 16, 2025
889a119
chore: clean up unnecessary descriptive comments
ScriptedAlchemy Jul 16, 2025
fa64cf1
fix: resolve clippy warnings for format\! string usage
ScriptedAlchemy Jul 16, 2025
5cec94b
perf: optimize ShareUsagePlugin binary size
ScriptedAlchemy Jul 16, 2025
96afd41
Resolve merge conflict in binding.d.ts
ScriptedAlchemy Jul 19, 2025
4345cad
feat(plugin_mf): add chunk characteristics to share usage plugin
ScriptedAlchemy Jul 21, 2025
c324c6f
Merge main branch and fix chunk characteristics implementation
ScriptedAlchemy Jul 21, 2025
294790b
chore: update napi-binding.d.ts after build
ScriptedAlchemy Jul 21, 2025
38954f2
fix: resolve clippy warnings in rspack_plugin_mf
ScriptedAlchemy Jul 21, 2025
508b29a
Refactor ShareUsagePlugin output format to new structure
ScriptedAlchemy Jul 22, 2025
7bcd64a
Merge latest main branch updates
ScriptedAlchemy Jul 22, 2025
ee6b82b
fix: resolve build errors from main merge
ScriptedAlchemy Jul 22, 2025
5f9ff85
Merge branch 'main' into swc-macro
ScriptedAlchemy Jul 24, 2025
f253f8d
fix(mf): correct treeShaeke typo to treeShake in ShareUsagePlugin
ScriptedAlchemy Jul 24, 2025
1c16f48
Merge branch 'main' into swc-macro
ScriptedAlchemy Jul 24, 2025
87c1f0f
refactor: remove unused is_shared_chunk field from ChunkCharacteristics
ScriptedAlchemy Aug 2, 2025
38dd8d0
Merge branch 'main' into swc-macro
ScriptedAlchemy Aug 2, 2025
eaca575
fix: add missing find_fallback_module_id method to ConsumeSharedModule
ScriptedAlchemy Aug 2, 2025
4cd228a
fix: register ConsumeSharedExportsDependencyTemplate and update snaps…
ScriptedAlchemy Aug 2, 2025
16ffafa
chore: locks
ScriptedAlchemy Aug 2, 2025
8010488
refactor: move ShareUsagePlugin to ModuleFederationRuntimePlugin
ScriptedAlchemy Aug 2, 2025
faaed3c
style: fix clippy collapsible_if warning in ConsumeSharedModule
ScriptedAlchemy Aug 2, 2025
79f9dd1
fix(mf): resolve syntax error in share_usage_plugin.rs
ScriptedAlchemy Aug 2, 2025
e16366b
Merge branch 'main' into swc-macro
ScriptedAlchemy Aug 16, 2025
900d905
fix: resolve compilation issues and clippy warnings
ScriptedAlchemy Aug 16, 2025
6b1efda
fix: resolve clippy collapsible_if warning in consume_shared_plugin.rs
ScriptedAlchemy Aug 16, 2025
bef5a44
chore: trigger CI rebuild
ScriptedAlchemy Aug 16, 2025
f56bb94
fix: rustfmt formatting issues
ScriptedAlchemy Aug 16, 2025
3205083
fix: track inter-shared-module dependencies in ShareUsagePlugin
ScriptedAlchemy Aug 16, 2025
538e663
fix: remove unused variable warning in share_usage_plugin.rs
ScriptedAlchemy Aug 16, 2025
9cab6e2
fix: update share-usage-inter-dependency test configuration
ScriptedAlchemy Aug 16, 2025
5142140
fix: remove explicit ShareUsagePlugin (auto-added by ModuleFederation…
ScriptedAlchemy Aug 16, 2025
e2ecca7
test: use mocked modules instead of real npm dependencies
ScriptedAlchemy Aug 16, 2025
db16332
refactor: restructure rspack_binding_api and add virtual modules support
ScriptedAlchemy Aug 16, 2025
8d44971
feat: add module federation tree-shaking support to rspack_core
ScriptedAlchemy Aug 16, 2025
6554cb1
fix: merge module federation tree-shaking changes with main branch
ScriptedAlchemy Aug 16, 2025
30f1190
test: update snapshots for module federation tree-shaking macro annot…
ScriptedAlchemy Aug 16, 2025
fbdc53e
fix: resolve lint warnings in example files
ScriptedAlchemy Aug 16, 2025
11e47b3
chore: exclude examples/basic from biome linting
ScriptedAlchemy Aug 16, 2025
681a414
chore: remove macro sys
ScriptedAlchemy Aug 16, 2025
69937c5
feat: enhance CommonJS export tracking in ShareUsagePlugin
ScriptedAlchemy Aug 17, 2025
11b7849
test: add CommonJS export tracking tests for ShareUsagePlugin
ScriptedAlchemy Aug 17, 2025
50584df
test: update share-usage-plugin tests to validate JSON output
ScriptedAlchemy Aug 17, 2025
8680ef4
fix: attempt to fix ESM module export tracking in ShareUsagePlugin
ScriptedAlchemy Aug 17, 2025
ec4d55c
fix: restore lost ESM export tracking logic in ShareUsagePlugin
ScriptedAlchemy Aug 17, 2025
67dc19d
fix: resolve clippy warnings in share_usage_plugin.rs
ScriptedAlchemy Aug 17, 2025
dd71bcd
Merge branch 'main' into swc-macro
ScriptedAlchemy Aug 17, 2025
aa967bc
test: fix share-usage-commonjs test configuration
ScriptedAlchemy Aug 17, 2025
08f21d4
fix: use valid identifier for Module Federation name
ScriptedAlchemy Aug 17, 2025
d74f89a
fix: revert unintended WASI file changes
ScriptedAlchemy Aug 17, 2025
098b3da
fix: add async boundary to share-usage-commonjs test
ScriptedAlchemy Aug 17, 2025
ad22c21
fix: correct test pattern for share-usage-commonjs
ScriptedAlchemy Aug 17, 2025
13247ad
fix: adjust test expectations for CommonJS export tracking
ScriptedAlchemy Aug 17, 2025
02fa46f
fix: remove generated WASI files that should not be committed
ScriptedAlchemy Aug 17, 2025
76ee9bc
fix: add missing RequestType exports for browser build
ScriptedAlchemy Aug 17, 2025
5d6242b
Update rspack.wasi-browser.js
ScriptedAlchemy Aug 17, 2025
84d8ac8
Update rspack.wasi.cjs
ScriptedAlchemy Aug 17, 2025
ed18724
fix: revert build script changes to use main branch version
ScriptedAlchemy Aug 17, 2025
42019ac
feat: add module federation React example with SWC macro WASM package
ScriptedAlchemy Aug 19, 2025
0d18934
locks
ScriptedAlchemy Aug 19, 2025
7387e72
docs: fact-check and update RFC on annotation-guided pruning of share…
ScriptedAlchemy Aug 19, 2025
4dd4068
docs: transform module federation tree-shaking analysis into formal RFC
ScriptedAlchemy Aug 19, 2025
2294396
chore: remove old example
ScriptedAlchemy Aug 19, 2025
861a1f8
chore: remove old example
ScriptedAlchemy Aug 19, 2025
b92f020
chore: remove old example
ScriptedAlchemy Aug 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 86 additions & 84 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,86 +1,88 @@
{
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug Rspack",
"program": "node",
"args": [
"packages/rspack-cli/bin/rspack.js",
"${input:rspackCommand}",
"-c",
"${input:rspackConfigPath}"
],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug Jest Test",
"program": "node",
"args": [
"--experimental-vm-modules",
"../../node_modules/jest-cli/bin/jest",
"--runInBand",
"${input:pickTestFile}",
"-t",
"${input:pickPattern}"
],
"cwd": "${workspaceFolder}/packages/rspack-test-tools",
"initCommands": ["settings set target.process.follow-fork-mode child"]
},
{
"name": "Attach JavaScript",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"type": "lldb",
"request": "attach",
"name": "Attach Rust",
"pid": "${command:pickMyProcess}"
},
],
"inputs": [
{
"id": "pickTest",
"type": "command",
"command": "extension.pickTest",
},
{
"id": "rspackCommand",
"type": "pickString",
"options": [
"build",
"dev"
],
"description": "choose build or dev mode",
"default": "dev"
},
{
"id": "rspackConfigPath",
"type": "promptString",
"description": "the rspack config path of your project",
"default": "examples/basic/rspack.config.cjs"
},
{
"id": "pickTestFile",
"type": "command",
"command": "shellCommand.execute",
"args": {
"command":"ls -alh packages/rspack-test-tools/tests/*.test.js | awk {'print $9'}",
"description": "pick test file"
}
},
{
"id": "pickPattern",
"type": "promptString",
"description": "pattern to filter test files",
"default": ""
}
]
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug Rspack",
"program": "node",
"args": [
"packages/rspack-cli/bin/rspack.js",
"${input:rspackCommand}",
"-c",
"${input:rspackConfigPath}"
],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug Jest Test",
"program": "node",
"args": [
"--experimental-vm-modules",
"../../node_modules/jest-cli/bin/jest",
"--runInBand",
"${input:pickTestFile}",
"-t",
"${input:pickPattern}"
],
"cwd": "${workspaceFolder}/packages/rspack-test-tools",
"initCommands": [
"settings set target.process.follow-fork-mode child"
]
},
{
"name": "Attach JavaScript",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"type": "lldb",
"request": "attach",
"name": "Attach Rust",
"pid": "${command:pickMyProcess}"
}
],
"inputs": [
{
"id": "pickTest",
"type": "command",
"command": "extension.pickTest"
},
{
"id": "rspackCommand",
"type": "pickString",
"options": [
"build",
"dev"
],
"description": "choose build or dev mode",
"default": "dev"
},
{
"id": "rspackConfigPath",
"type": "promptString",
"description": "the rspack config path of your project",
"default": "examples/basic/rspack.config.cjs"
},
{
"id": "pickTestFile",
"type": "command",
"command": "shellCommand.execute",
"args": {
"command": "ls -alh packages/rspack-test-tools/tests/*.test.js | awk {'print $9'}",
"description": "pick test file"
}
},
{
"id": "pickPattern",
"type": "promptString",
"description": "pattern to filter test files",
"default": ""
}
]
}
6 changes: 5 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@
"!**/packages/rspack-test-tools/template/*",
// --- ignore runtime code in browser
"!**/packages/rspack/hot",
"!**/packages/rspack/src/runtime/moduleFederationDefaultRuntime.js"
"!**/packages/rspack/src/runtime/moduleFederationDefaultRuntime.js",
// --- ignore examples/basic test directory
"!**/examples/basic/**/*",
// --- ignore generated WASM files
"!**/examples/swc_macro_wasm_pkg/**/*"
],
"ignoreUnknown": true
},
Expand Down
4 changes: 2 additions & 2 deletions crates/node_binding/scripts/move-binding.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require("path");
const fs = require("fs");
const path = require("node:path");
const fs = require("node:fs");

console.log(__dirname);
const abslutePathBindingList = fs
Expand Down
4 changes: 4 additions & 0 deletions crates/rspack_binding_api/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,10 @@ impl From<JsBuildMeta> for BuildMeta {
default_object,
side_effect_free,
exports_final_name,
consume_shared_key: None,
shared_key: None,
is_shared_descendant: None,
effective_shared_key: None,
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/rspack_core/src/dependency/dependency_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub enum DependencyType {
CjsFullRequire,
// cjs exports
CjsExports,
// consume shared exports (tree-shaking variant)
ConsumeSharedExports,
// module.exports = require(), should bailout in old tree shaking
CjsExportRequire,
// cjs self reference
Expand Down Expand Up @@ -138,6 +140,7 @@ impl DependencyType {
DependencyType::CjsRequire => "cjs require",
DependencyType::CjsFullRequire => "cjs full require",
DependencyType::CjsExports => "cjs exports",
DependencyType::ConsumeSharedExports => "consume shared exports",
DependencyType::CjsExportRequire => "cjs export require",
DependencyType::CjsSelfReference => "cjs self exports reference",
DependencyType::AmdDefine => "amd define",
Expand Down
41 changes: 40 additions & 1 deletion crates/rspack_core/src/dependency/runtime_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ use crate::{
to_comment, to_normal_comment,
};

/// Check if a module is part of a shared bundle using BuildMeta only
/// This relies on the Module Federation plugin to populate BuildMeta.is_shared_descendant
fn is_consume_shared_descendant(module_graph: &ModuleGraph, module_id: &ModuleIdentifier) -> bool {
if let Some(module) = module_graph.module_by_identifier(module_id) {
let build_meta = module.build_meta();

// Use BuildMeta value (populated by Module Federation plugin)
// If not populated, assume false (no PURE annotations)
build_meta.is_shared_descendant.unwrap_or(false)
} else {
false
}
}

pub fn runtime_condition_expression(
chunk_graph: &ChunkGraph,
runtime_condition: Option<&RuntimeCondition>,
Expand Down Expand Up @@ -400,8 +414,21 @@ pub fn import_statement(

let opt_declaration = if update { "" } else { "var " };

// Apply PURE annotations only to descendants of ConsumeShared or ProvideShared modules
// This ensures the SWC macro transformer can remove unused __webpack_require__ calls in shared chunks
let is_pure = if let Some(module_identifier) = compilation
.get_module_graph()
.module_identifier_by_dependency_id(id)
{
is_consume_shared_descendant(&compilation.get_module_graph(), module_identifier)
} else {
false
};

let pure_annotation = if is_pure { "/* #__PURE__ */ " } else { "" };

let import_content = format!(
"/* ESM import */{opt_declaration}{import_var} = {}({module_id_expr});\n",
"/* ESM import */{opt_declaration}{import_var} = {pure_annotation}{}({module_id_expr});\n",
RuntimeGlobals::REQUIRE
);

Expand Down Expand Up @@ -903,3 +930,15 @@ mod test_items_to_regexp {
);
}
}

#[cfg(test)]
mod test_is_consume_shared_descendant {
use super::*;

#[test]
fn test_is_consume_shared_descendant_function_signature() {
// Test that the function exists and has the correct signature
// Verify function signature compiles correctly
let _: fn(&ModuleGraph, &ModuleIdentifier) -> bool = is_consume_shared_descendant;
}
}
20 changes: 20 additions & 0 deletions crates/rspack_core/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,20 @@ pub struct BuildMeta {
pub side_effect_free: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub exports_final_name: Option<Vec<(String, String)>>,

#[serde(skip_serializing_if = "Option::is_none")]
pub consume_shared_key: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub shared_key: Option<String>,

/// Cached result of shared descendant check to avoid expensive BFS traversals
#[serde(skip_serializing_if = "Option::is_none")]
pub is_shared_descendant: Option<bool>,

/// Unified shared key for both ESM and CommonJS (effective key after resolution)
#[serde(skip_serializing_if = "Option::is_none")]
pub effective_shared_key: Option<String>,
}

// webpack build info
Expand Down Expand Up @@ -417,6 +431,12 @@ pub trait Module:
fn need_id(&self) -> bool {
true
}

/// Get the share_key for ConsumeShared modules.
/// Returns None for non-ConsumeShared modules.
fn get_consume_shared_key(&self) -> Option<String> {
None
}
}

fn get_exports_type_impl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ impl DependencyTemplate for CommonJsExportRequireDependencyTemplate {
.module_by_identifier(&module.identifier())
.expect("should have mgm");

// Check if parent module is ConsumeShared and get share_key from options
// ConsumeShared tree-shaking macro support
let consume_shared_info: Option<String> = module.get_consume_shared_key();

let exports_argument = module.get_exports_argument();
let module_argument = module.get_module_argument();

Expand Down Expand Up @@ -527,7 +531,21 @@ impl DependencyTemplate for CommonJsExportRequireDependencyTemplate {
if dep.base.is_expression() {
let expr = match used {
Some(UsedName::Normal(used)) => {
format!("{base}{} = {require_expr}", property_access(used, 0))
let assignment = format!("{base}{} = {require_expr}", property_access(&used, 0));

// ConsumeShared tree-shaking macro support
if let Some(shared_key) = &consume_shared_info {
let export_name = used
.iter()
.map(|a| a.as_str())
.collect::<Vec<_>>()
.join(".");
format!(
"/* @common:if [condition=\"treeShake.{shared_key}.{export_name}\"] */ {assignment} /* @common:endif */"
)
} else {
assignment
}
}
Some(UsedName::Inlined(_)) => {
// Export a inlinable const from cjs is not possible for now but we compat it here
Expand Down
Loading
Loading