Skip to content

Commit 0a37e9e

Browse files
chore: fix conflicts
1 parent 6fa3596 commit 0a37e9e

File tree

3 files changed

+111
-22
lines changed

3 files changed

+111
-22
lines changed

packages/enhanced/src/lib/container/ContainerReferencePlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class ContainerReferencePlugin {
135135
//@ts-ignore
136136
config.shareScope,
137137
);
138-
hooks.addRemoteDependency.call(remoteModule);
138+
// Note: RemoteModule will call hooks.addRemoteDependency itself during build
139139
return remoteModule;
140140
}
141141
}

packages/enhanced/test/unit/container/RemoteModule.test.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ jest.mock('../../../src/lib/container/runtime/FederationModulesPlugin', () => {
4242
})),
4343
};
4444

45-
return mockFederationModulesPlugin;
45+
return {
46+
default: mockFederationModulesPlugin,
47+
...mockFederationModulesPlugin,
48+
};
4649
});
4750

4851
describe('RemoteModule', () => {
@@ -159,25 +162,21 @@ describe('RemoteModule', () => {
159162
let mockGetCompilationHooks: jest.SpyInstance;
160163

161164
beforeEach(() => {
162-
const FederationModulesPlugin =
163-
require('../../../src/lib/container/runtime/FederationModulesPlugin').default;
164-
// Mock the SyncHook instances more accurately
165-
const mockHook = () => ({
166-
tap: jest.fn(),
167-
call: jest.fn(), // Add the call method
168-
});
169-
170-
mockGetCompilationHooks = jest
171-
.spyOn(FederationModulesPlugin, 'getCompilationHooks')
172-
.mockReturnValue({
173-
addContainerEntryDependency: mockHook() as any,
174-
addFederationRuntimeDependency: mockHook() as any,
175-
addRemoteDependency: mockHook() as any,
176-
});
165+
// The mock is already set up in the module mock above
166+
// Just reference it for spying if needed
167+
const FederationModulesPlugin = require('../../../src/lib/container/runtime/FederationModulesPlugin');
168+
169+
// Since we already have a mock, we can just access it directly
170+
mockGetCompilationHooks =
171+
FederationModulesPlugin.getCompilationHooks ||
172+
FederationModulesPlugin.default?.getCompilationHooks;
177173
});
178174

179175
afterEach(() => {
180-
mockGetCompilationHooks.mockRestore();
176+
// Clear mocks but don't restore since it's a module mock
177+
if (mockGetCompilationHooks && mockGetCompilationHooks.mockClear) {
178+
mockGetCompilationHooks.mockClear();
179+
}
181180
});
182181

183182
it('should set buildInfo and buildMeta', () => {

packages/enhanced/test/unit/sharing/SharePlugin.test.ts

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ describe('SharePlugin', () => {
850850
ProvideSharedPluginMock.mockClear();
851851
});
852852

853-
it('should transform all properties from SharedConfig to ConsumesConfig', () => {
853+
it('should transform all properties from SharedConfig to ConsumesConfig with exclude', () => {
854854
const sharedConfig = {
855855
import: './path/to/module',
856856
shareKey: 'customKey',
@@ -865,7 +865,6 @@ describe('SharePlugin', () => {
865865
layer: 'layer',
866866
request: 'custom-request',
867867
exclude: { version: '^0.9.0' },
868-
include: { version: '^1.0.0' },
869868
};
870869

871870
const plugin = new SharePlugin({
@@ -897,11 +896,59 @@ describe('SharePlugin', () => {
897896
layer: sharedConfig.layer,
898897
request: sharedConfig.request,
899898
exclude: sharedConfig.exclude,
899+
});
900+
});
901+
902+
it('should transform all properties from SharedConfig to ConsumesConfig with include', () => {
903+
const sharedConfig = {
904+
import: './path/to/module',
905+
shareKey: 'customKey',
906+
shareScope: 'customScope',
907+
requiredVersion: '^1.0.0',
908+
strictVersion: true,
909+
singleton: true,
910+
packageName: 'my-package',
911+
eager: true,
912+
version: '1.0.0',
913+
issuerLayer: 'issuerLayer',
914+
layer: 'layer',
915+
request: 'custom-request',
916+
include: { version: '^1.0.0' },
917+
};
918+
919+
const plugin = new SharePlugin({
920+
shared: {
921+
react: sharedConfig,
922+
},
923+
});
924+
925+
plugin.apply(mockCompiler);
926+
927+
// Check ConsumeSharedPlugin properties
928+
expect(ConsumeSharedPluginMock).toHaveBeenCalledTimes(1);
929+
const consumeOptions = ConsumeSharedPluginMock.mock.calls[0][0];
930+
const reactConsume = consumeOptions.consumes.find(
931+
(consume) => Object.keys(consume)[0] === 'react',
932+
);
933+
934+
// All expected properties should be passed through
935+
expect(reactConsume.react).toMatchObject({
936+
import: sharedConfig.import,
937+
shareKey: sharedConfig.shareKey,
938+
shareScope: sharedConfig.shareScope,
939+
requiredVersion: sharedConfig.requiredVersion,
940+
strictVersion: sharedConfig.strictVersion,
941+
singleton: sharedConfig.singleton,
942+
packageName: sharedConfig.packageName,
943+
eager: sharedConfig.eager,
944+
issuerLayer: sharedConfig.issuerLayer,
945+
layer: sharedConfig.layer,
946+
request: sharedConfig.request,
900947
include: sharedConfig.include,
901948
});
902949
});
903950

904-
it('should transform all properties from SharedConfig to ProvidesConfig', () => {
951+
it('should transform all properties from SharedConfig to ProvidesConfig with exclude', () => {
905952
const sharedConfig = {
906953
import: './path/to/module',
907954
shareKey: 'customKey',
@@ -914,7 +961,6 @@ describe('SharePlugin', () => {
914961
layer: 'layer',
915962
request: 'custom-request',
916963
exclude: { version: '^0.9.0' },
917-
include: { version: '^1.0.0' },
918964
};
919965

920966
const plugin = new SharePlugin({
@@ -944,6 +990,50 @@ describe('SharePlugin', () => {
944990
layer: sharedConfig.layer,
945991
request: sharedConfig.request,
946992
exclude: sharedConfig.exclude,
993+
});
994+
});
995+
996+
it('should transform all properties from SharedConfig to ProvidesConfig with include', () => {
997+
const sharedConfig = {
998+
import: './path/to/module',
999+
shareKey: 'customKey',
1000+
shareScope: 'customScope',
1001+
version: '1.0.0',
1002+
eager: true,
1003+
requiredVersion: '^1.0.0',
1004+
strictVersion: true,
1005+
singleton: true,
1006+
layer: 'layer',
1007+
request: 'custom-request',
1008+
include: { version: '^1.0.0' },
1009+
};
1010+
1011+
const plugin = new SharePlugin({
1012+
shared: {
1013+
react: sharedConfig,
1014+
},
1015+
});
1016+
1017+
plugin.apply(mockCompiler);
1018+
1019+
// Check ProvideSharedPlugin properties
1020+
expect(ProvideSharedPluginMock).toHaveBeenCalledTimes(1);
1021+
const provideOptions = ProvideSharedPluginMock.mock.calls[0][0];
1022+
const reactProvide = provideOptions.provides.find(
1023+
(provide) => Object.keys(provide)[0] === './path/to/module',
1024+
);
1025+
1026+
// All expected properties should be passed through
1027+
expect(reactProvide['./path/to/module']).toMatchObject({
1028+
shareKey: sharedConfig.shareKey,
1029+
shareScope: sharedConfig.shareScope,
1030+
version: sharedConfig.version,
1031+
eager: sharedConfig.eager,
1032+
requiredVersion: sharedConfig.requiredVersion,
1033+
strictVersion: sharedConfig.strictVersion,
1034+
singleton: sharedConfig.singleton,
1035+
layer: sharedConfig.layer,
1036+
request: sharedConfig.request,
9471037
include: sharedConfig.include,
9481038
});
9491039
});

0 commit comments

Comments
 (0)