Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions packages/repack/src/plugins/__tests__/DevelopmentPlugin.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<typeof import('@module-federation/enhanced/rspack')>(
'@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' }),
]);
Expand Down
2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading