diff --git a/packages/repack/src/plugins/__tests__/DevelopmentPlugin.test.ts b/packages/repack/src/plugins/__tests__/DevelopmentPlugin.test.ts index 2d7e2440f..0708d6bc1 100644 --- a/packages/repack/src/plugins/__tests__/DevelopmentPlugin.test.ts +++ b/packages/repack/src/plugins/__tests__/DevelopmentPlugin.test.ts @@ -1,4 +1,3 @@ -import { ModuleFederationPlugin as MFPluginRspack } from '@module-federation/enhanced/rspack'; import type { Compiler, EntryNormalized } from '@rspack/core'; import { DevelopmentPlugin } from '../DevelopmentPlugin.js'; import { ModuleFederationPluginV2 } from '../ModuleFederationPluginV2.js'; @@ -46,17 +45,36 @@ const createMockCompiler = (plugins: unknown[]) => { }; }; +// Module Federation 2.x loads undici 7, which requires Node >= 20.18.1, +// so the official plugin can only be loaded on newer Node versions. +const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(Number); +const itWithOfficialMF = + nodeMajor > 20 || (nodeMajor === 20 && nodeMinor >= 18) ? it : it.skip; + +const loadMFPluginRspack = () => + jest.requireActual( + '@module-federation/enhanced/rspack' + ).ModuleFederationPlugin; + describe('DevelopmentPlugin', () => { - it('should add development entries to the container of an official MF plugin with exposes', () => { - const { compiler, getEntryNames } = createMockCompiler([ - new MFPluginRspack({ name: 'remote', exposes: { './App': './App.js' } }), - ]); - new DevelopmentPlugin({ platform: 'ios' }).apply(compiler); + itWithOfficialMF( + 'should add development entries to the container of an official MF plugin with exposes', + () => { + const MFPluginRspack = loadMFPluginRspack(); + const { compiler, getEntryNames } = createMockCompiler([ + new MFPluginRspack({ + name: 'remote', + exposes: { './App': './App.js' }, + }), + ]); + new DevelopmentPlugin({ platform: 'ios' }).apply(compiler); - expect(getEntryNames()).toEqual(['main', 'remote']); - }); + expect(getEntryNames()).toEqual(['main', 'remote']); + } + ); - it('should skip an official MF plugin without exposes', () => { + itWithOfficialMF('should skip an official MF plugin without exposes', () => { + const MFPluginRspack = loadMFPluginRspack(); const { compiler, getEntryNames } = createMockCompiler([ new MFPluginRspack({ name: 'host' }), ]); diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e7b3b4548..3696e70c5 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -15,7 +15,7 @@ overrides: # Security fixes for advisories in @module-federation/dts-plugin, which pins # these to exact versions. Current MF releases are fixed; these are only # still reached through the older MF versions pinned on purpose for - # compatibility coverage (packages/repack and tests/integration devDeps). + # compatibility coverage (tests/integration devDeps). "koa@2": ^2.16.4 "koa@3": ^3.1.2 "ws@8": ^8.21.1