diff --git a/.changeset/hot-grapes-shop.md b/.changeset/hot-grapes-shop.md new file mode 100644 index 000000000000..52bf3f309b08 --- /dev/null +++ b/.changeset/hot-grapes-shop.md @@ -0,0 +1,7 @@ +--- +'@modern-js/app-tools': patch +'@modern-js/utils': patch +--- + +chore(app-tools): add RouterPlugin name +chore(app-tools): 增加 RouterPlugin 名称 diff --git a/packages/solutions/app-tools/src/builder/shared/builderPlugins/adapterSSR.ts b/packages/solutions/app-tools/src/builder/shared/builderPlugins/adapterSSR.ts index edcb6470e035..341a44a19875 100644 --- a/packages/solutions/app-tools/src/builder/shared/builderPlugins/adapterSSR.ts +++ b/packages/solutions/app-tools/src/builder/shared/builderPlugins/adapterSSR.ts @@ -44,7 +44,12 @@ export const builderPluginAdapterSSR = ( const builderConfig = api.getNormalizedConfig(); const { normalizedConfig } = options; - applyRouterPlugin(chain, options, HtmlBundlerPlugin); + applyRouterPlugin( + chain, + CHAIN_ID.PLUGIN.ROUTER_MANIFEST, + options, + HtmlBundlerPlugin, + ); if (isSSR(normalizedConfig)) { await applySSRLoaderEntry(chain, options, isServer); applySSRDataLoader(chain, options); @@ -114,6 +119,7 @@ function applyAsyncChunkHtmlPlugin({ function applyRouterPlugin( chain: BundlerChain, + pluginName: string, options: Readonly>, HtmlBundlerPlugin: typeof HtmlWebpackPlugin, ) { @@ -128,7 +134,7 @@ function applyRouterPlugin( const workerSSR = Boolean(normalizedConfig.deploy.worker?.ssr); if (existNestedRoutes || routerManifest || workerSSR) { - chain.plugin('route-plugin').use(RouterPlugin, [ + chain.plugin(pluginName).use(RouterPlugin, [ { HtmlBundlerPlugin, enableInlineRouteManifests: diff --git a/packages/solutions/app-tools/src/builder/shared/bundlerPlugins/RouterPlugin.ts b/packages/solutions/app-tools/src/builder/shared/bundlerPlugins/RouterPlugin.ts index 4b98e4e4cc27..32bfe4fc391f 100644 --- a/packages/solutions/app-tools/src/builder/shared/bundlerPlugins/RouterPlugin.ts +++ b/packages/solutions/app-tools/src/builder/shared/bundlerPlugins/RouterPlugin.ts @@ -35,6 +35,8 @@ const generateContentHash = (content: string) => { }; export class RouterPlugin { + readonly name: string = 'RouterPlugin'; + private HtmlBundlerPlugin: typeof HtmlWebpackPlugin; private enableInlineRouteManifests: boolean; diff --git a/packages/toolkit/utils/src/cli/constants/chainId.ts b/packages/toolkit/utils/src/cli/constants/chainId.ts index 09f13f42579e..24bba97f8c3f 100644 --- a/packages/toolkit/utils/src/cli/constants/chainId.ts +++ b/packages/toolkit/utils/src/cli/constants/chainId.ts @@ -170,6 +170,8 @@ export const CHAIN_ID = { HTML_ASYNC_CHUNK: 'html-async-chunk', /** SWC_POLYFILL_CHECKER */ SWC_POLYFILL_CHECKER: 'swc-polyfill-checker-plugin', + /** RouterPlugin */ + ROUTER_MANIFEST: 'route-plugin', }, /** Predefined minimizers */ MINIMIZER: {