Skip to content

Commit a66c266

Browse files
chore: fix conflicts
1 parent 30f26c6 commit a66c266

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
@@ -814,7 +814,7 @@ describe('SharePlugin', () => {
814814
ProvideSharedPluginMock.mockClear();
815815
});
816816

817-
it('should transform all properties from SharedConfig to ConsumesConfig', () => {
817+
it('should transform all properties from SharedConfig to ConsumesConfig with exclude', () => {
818818
const sharedConfig = {
819819
import: './path/to/module',
820820
shareKey: 'customKey',
@@ -829,7 +829,6 @@ describe('SharePlugin', () => {
829829
layer: 'layer',
830830
request: 'custom-request',
831831
exclude: { version: '^0.9.0' },
832-
include: { version: '^1.0.0' },
833832
};
834833

835834
const plugin = new SharePlugin({
@@ -861,11 +860,59 @@ describe('SharePlugin', () => {
861860
layer: sharedConfig.layer,
862861
request: sharedConfig.request,
863862
exclude: sharedConfig.exclude,
863+
});
864+
});
865+
866+
it('should transform all properties from SharedConfig to ConsumesConfig with include', () => {
867+
const sharedConfig = {
868+
import: './path/to/module',
869+
shareKey: 'customKey',
870+
shareScope: 'customScope',
871+
requiredVersion: '^1.0.0',
872+
strictVersion: true,
873+
singleton: true,
874+
packageName: 'my-package',
875+
eager: true,
876+
version: '1.0.0',
877+
issuerLayer: 'issuerLayer',
878+
layer: 'layer',
879+
request: 'custom-request',
880+
include: { version: '^1.0.0' },
881+
};
882+
883+
const plugin = new SharePlugin({
884+
shared: {
885+
react: sharedConfig,
886+
},
887+
});
888+
889+
plugin.apply(mockCompiler);
890+
891+
// Check ConsumeSharedPlugin properties
892+
expect(ConsumeSharedPluginMock).toHaveBeenCalledTimes(1);
893+
const consumeOptions = ConsumeSharedPluginMock.mock.calls[0][0];
894+
const reactConsume = consumeOptions.consumes.find(
895+
(consume) => Object.keys(consume)[0] === 'react',
896+
);
897+
898+
// All expected properties should be passed through
899+
expect(reactConsume.react).toMatchObject({
900+
import: sharedConfig.import,
901+
shareKey: sharedConfig.shareKey,
902+
shareScope: sharedConfig.shareScope,
903+
requiredVersion: sharedConfig.requiredVersion,
904+
strictVersion: sharedConfig.strictVersion,
905+
singleton: sharedConfig.singleton,
906+
packageName: sharedConfig.packageName,
907+
eager: sharedConfig.eager,
908+
issuerLayer: sharedConfig.issuerLayer,
909+
layer: sharedConfig.layer,
910+
request: sharedConfig.request,
864911
include: sharedConfig.include,
865912
});
866913
});
867914

868-
it('should transform all properties from SharedConfig to ProvidesConfig', () => {
915+
it('should transform all properties from SharedConfig to ProvidesConfig with exclude', () => {
869916
const sharedConfig = {
870917
import: './path/to/module',
871918
shareKey: 'customKey',
@@ -878,7 +925,6 @@ describe('SharePlugin', () => {
878925
layer: 'layer',
879926
request: 'custom-request',
880927
exclude: { version: '^0.9.0' },
881-
include: { version: '^1.0.0' },
882928
};
883929

884930
const plugin = new SharePlugin({
@@ -908,6 +954,50 @@ describe('SharePlugin', () => {
908954
layer: sharedConfig.layer,
909955
request: sharedConfig.request,
910956
exclude: sharedConfig.exclude,
957+
});
958+
});
959+
960+
it('should transform all properties from SharedConfig to ProvidesConfig with include', () => {
961+
const sharedConfig = {
962+
import: './path/to/module',
963+
shareKey: 'customKey',
964+
shareScope: 'customScope',
965+
version: '1.0.0',
966+
eager: true,
967+
requiredVersion: '^1.0.0',
968+
strictVersion: true,
969+
singleton: true,
970+
layer: 'layer',
971+
request: 'custom-request',
972+
include: { version: '^1.0.0' },
973+
};
974+
975+
const plugin = new SharePlugin({
976+
shared: {
977+
react: sharedConfig,
978+
},
979+
});
980+
981+
plugin.apply(mockCompiler);
982+
983+
// Check ProvideSharedPlugin properties
984+
expect(ProvideSharedPluginMock).toHaveBeenCalledTimes(1);
985+
const provideOptions = ProvideSharedPluginMock.mock.calls[0][0];
986+
const reactProvide = provideOptions.provides.find(
987+
(provide) => Object.keys(provide)[0] === './path/to/module',
988+
);
989+
990+
// All expected properties should be passed through
991+
expect(reactProvide['./path/to/module']).toMatchObject({
992+
shareKey: sharedConfig.shareKey,
993+
shareScope: sharedConfig.shareScope,
994+
version: sharedConfig.version,
995+
eager: sharedConfig.eager,
996+
requiredVersion: sharedConfig.requiredVersion,
997+
strictVersion: sharedConfig.strictVersion,
998+
singleton: sharedConfig.singleton,
999+
layer: sharedConfig.layer,
1000+
request: sharedConfig.request,
9111001
include: sharedConfig.include,
9121002
});
9131003
});

0 commit comments

Comments
 (0)