File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ import type {
4242import { getDefaultExtension } from './utils/extension' ;
4343import {
4444 calcLongestCommonPath ,
45+ checkMFPlugin ,
4546 color ,
4647 isEmptyObject ,
4748 isObject ,
@@ -919,6 +920,7 @@ const composeExternalHelpersConfig = (
919920} ;
920921
921922async function composeLibRsbuildConfig ( config : LibConfig , configPath : string ) {
923+ checkMFPlugin ( config ) ;
922924 const rootPath = dirname ( configPath ) ;
923925 const pkgJson = readPackageJson ( rootPath ) ;
924926 const { compilerOptions } = await loadTsconfig (
Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ import fs from 'node:fs';
22import fsP from 'node:fs/promises' ;
33import path from 'node:path' ;
44import color from 'picocolors' ;
5- import type { PkgJson } from '../types' ;
5+
6+ import type { LibConfig , PkgJson } from '../types' ;
67import { logger } from './logger' ;
78
89/**
@@ -160,4 +161,35 @@ export function omit<T extends object, U extends keyof T>(
160161 ) ;
161162}
162163
164+ export function isPluginIncluded (
165+ config : LibConfig ,
166+ pluginName : string ,
167+ ) : boolean {
168+ return Boolean (
169+ config . plugins ?. some ( ( plugin ) => {
170+ if ( typeof plugin === 'object' && plugin !== null && 'name' in plugin ) {
171+ return plugin . name === pluginName ;
172+ }
173+ return false ;
174+ } ) ,
175+ ) ;
176+ }
177+
178+ export function checkMFPlugin ( config : LibConfig ) : boolean {
179+ if ( config . format !== 'mf' ) {
180+ return true ;
181+ }
182+
183+ const added = isPluginIncluded ( config , 'rsbuild:module-federation-enhanced' ) ;
184+ if ( ! added ) {
185+ logger . warn (
186+ `${ color . green ( 'mf format' ) } is enabled, but the ${ color . blue (
187+ '@module-federation/rsbuild-plugin' ,
188+ ) } plugin was not found in plugins.`,
189+ ) ;
190+ process . exit ( 1 ) ;
191+ }
192+ return added ;
193+ }
194+
163195export { color } ;
You can’t perform that action at this time.
0 commit comments