From 4e1423c07e8fde26ef43e9d6a03b9a8c2ddf0b5e Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Tue, 13 Oct 2026 13:09:36 +0100 Subject: [PATCH] test(repack): skip official MF plugin tests on Node < 20.18 @module-federation/enhanced 2.x loads undici 7, which needs Node >= 20.18.1 (global File), so DevelopmentPlugin.test.ts failed to load on Node 18 after the devDependency moved to 2.9.2. Load the official plugin lazily and skip only the two tests that need it on older Node; the Re.Pack plugin test still runs everywhere. Also drop packages/repack from the overrides comment, which no longer pins an older MF version. --- .../__tests__/DevelopmentPlugin.test.ts | 36 ++++++++++++++----- pnpm-workspace.yaml | 2 +- 2 files changed, 28 insertions(+), 10 deletions(-) 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