Skip to content

Commit 17cc609

Browse files
committed
fix: correct secondary field
1 parent cd42e76 commit 17cc609

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

apps/website-new/src/components/en/secondary-build.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ If your goal is “tree-shake a shared dependency for a single application”, [
66
This section is about generating a standalone secondary artifact that can be loaded at runtime on demand, and can be distributed or reused from the deployment side.
77
:::
88

9+
This process builds only shared dependencies; remotes will not take effect. The original project entry is automatically ignored during the build, and only shared modules are bundled.
10+
911
### Non-Modern.js projects
1012

1113
Use `TreeShakingSharedPlugin` in your build configuration, set `secondary: true`, and reuse your existing `mfConfig`.

apps/website-new/src/components/zh/secondary-build.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
本节介绍的是生成一份可被运行时按需加载的独立共享产物(secondary),用于在部署侧统一下发或复用。
77
:::
88

9-
### 非 Modern.js 项目
9+
该过程只构建共享依赖,remotes 不会生效,因此构建前请确保项目入口(entry)只引入了共享依赖。
10+
11+
###### 非 Modern.js 项目
1012

1113
在构建配置中使用 `TreeShakingSharedPlugin`,设置 `secondary: true`,并复用现有的 `mfConfig`
1214

packages/modernjs/src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const moduleFederationPlugin = (
5353
if (isWebTarget(chain.get('target'))) {
5454
if (secondarySharedTreeShaking) {
5555
chain
56-
.plugin('plugin-module-federation-tree-shaking')
56+
.plugin('plugin-module-federation')
5757
.use(TreeShakingSharedPlugin, [
5858
{
5959
mfConfig: browserPluginOptions,

packages/modernjs/src/cli/ssrPlugin.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,12 @@ export const moduleFederationSSRPlugin = (
297297
if (!isWeb) {
298298
if (!chain.plugins.has(CHAIN_MF_PLUGIN_ID)) {
299299
if (secondarySharedTreeShaking) {
300-
chain
301-
.plugin(`${CHAIN_MF_PLUGIN_ID}-tree-shaking`)
302-
.use(TreeShakingSharedPlugin, [
303-
{
304-
mfConfig: pluginOptions.ssrConfig,
305-
secondary: true,
306-
},
307-
]);
300+
chain.plugin(CHAIN_MF_PLUGIN_ID).use(TreeShakingSharedPlugin, [
301+
{
302+
mfConfig: pluginOptions.ssrConfig,
303+
secondary: true,
304+
},
305+
]);
308306
} else {
309307
chain
310308
.plugin(CHAIN_MF_PLUGIN_ID)

0 commit comments

Comments
 (0)