Skip to content

Commit aed1802

Browse files
authored
test(repack): skip official MF plugin tests on Node < 20.18 (#1498)
1 parent 253d14b commit aed1802

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

‎packages/repack/src/plugins/__tests__/DevelopmentPlugin.test.ts‎

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { ModuleFederationPlugin as MFPluginRspack } from '@module-federation/enhanced/rspack';
21
import type { Compiler, EntryNormalized } from '@rspack/core';
32
import { DevelopmentPlugin } from '../DevelopmentPlugin.js';
43
import { ModuleFederationPluginV2 } from '../ModuleFederationPluginV2.js';
@@ -46,17 +45,36 @@ const createMockCompiler = (plugins: unknown[]) => {
4645
};
4746
};
4847

48+
// Module Federation 2.x loads undici 7, which requires Node >= 20.18.1,
49+
// so the official plugin can only be loaded on newer Node versions.
50+
const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(Number);
51+
const itWithOfficialMF =
52+
nodeMajor > 20 || (nodeMajor === 20 && nodeMinor >= 18) ? it : it.skip;
53+
54+
const loadMFPluginRspack = () =>
55+
jest.requireActual<typeof import('@module-federation/enhanced/rspack')>(
56+
'@module-federation/enhanced/rspack'
57+
).ModuleFederationPlugin;
58+
4959
describe('DevelopmentPlugin', () => {
50-
it('should add development entries to the container of an official MF plugin with exposes', () => {
51-
const { compiler, getEntryNames } = createMockCompiler([
52-
new MFPluginRspack({ name: 'remote', exposes: { './App': './App.js' } }),
53-
]);
54-
new DevelopmentPlugin({ platform: 'ios' }).apply(compiler);
60+
itWithOfficialMF(
61+
'should add development entries to the container of an official MF plugin with exposes',
62+
() => {
63+
const MFPluginRspack = loadMFPluginRspack();
64+
const { compiler, getEntryNames } = createMockCompiler([
65+
new MFPluginRspack({
66+
name: 'remote',
67+
exposes: { './App': './App.js' },
68+
}),
69+
]);
70+
new DevelopmentPlugin({ platform: 'ios' }).apply(compiler);
5571

56-
expect(getEntryNames()).toEqual(['main', 'remote']);
57-
});
72+
expect(getEntryNames()).toEqual(['main', 'remote']);
73+
}
74+
);
5875

59-
it('should skip an official MF plugin without exposes', () => {
76+
itWithOfficialMF('should skip an official MF plugin without exposes', () => {
77+
const MFPluginRspack = loadMFPluginRspack();
6078
const { compiler, getEntryNames } = createMockCompiler([
6179
new MFPluginRspack({ name: 'host' }),
6280
]);

‎pnpm-workspace.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ overrides:
1515
# Security fixes for advisories in @module-federation/dts-plugin, which pins
1616
# these to exact versions. Current MF releases are fixed; these are only
1717
# still reached through the older MF versions pinned on purpose for
18-
# compatibility coverage (packages/repack and tests/integration devDeps).
18+
# compatibility coverage (tests/integration devDeps).
1919
"koa@2": ^2.16.4
2020
"koa@3": ^3.1.2
2121
"ws@8": ^8.21.1

0 commit comments

Comments
 (0)