|
1 | | -import { ModuleFederationPlugin as MFPluginRspack } from '@module-federation/enhanced/rspack'; |
2 | 1 | import type { Compiler, EntryNormalized } from '@rspack/core'; |
3 | 2 | import { DevelopmentPlugin } from '../DevelopmentPlugin.js'; |
4 | 3 | import { ModuleFederationPluginV2 } from '../ModuleFederationPluginV2.js'; |
@@ -46,17 +45,36 @@ const createMockCompiler = (plugins: unknown[]) => { |
46 | 45 | }; |
47 | 46 | }; |
48 | 47 |
|
| 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 | + |
49 | 59 | 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); |
55 | 71 |
|
56 | | - expect(getEntryNames()).toEqual(['main', 'remote']); |
57 | | - }); |
| 72 | + expect(getEntryNames()).toEqual(['main', 'remote']); |
| 73 | + } |
| 74 | + ); |
58 | 75 |
|
59 | | - it('should skip an official MF plugin without exposes', () => { |
| 76 | + itWithOfficialMF('should skip an official MF plugin without exposes', () => { |
| 77 | + const MFPluginRspack = loadMFPluginRspack(); |
60 | 78 | const { compiler, getEntryNames } = createMockCompiler([ |
61 | 79 | new MFPluginRspack({ name: 'host' }), |
62 | 80 | ]); |
|
0 commit comments