Skip to content

Commit fa3f399

Browse files
Merge branch 'main' into rsbuild-rslib-convert
Integrate latest changes from origin/main: - chore(deps-dev): bump publint from 0.2.12 to 0.3.13 (#4109) - chore(deps): bump @changesets/get-dependents-graph from 2.1.2 to 2.1.3 (#4110) - fix enhanced type tests (#4113) - fix(enhanced): Add fallback parsing for container module exposes (#4034) (#4083) Resolved pnpm-lock.yaml conflict by regenerating the lockfile. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
2 parents f9a7b8f + 9de67b6 commit fa3f399

File tree

58 files changed

+4785
-5357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4785
-5357
lines changed

.changeset/friendly-lions-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/bridge-react': patch
3+
---
4+
5+
test(bridge-react): stabilize async assertions for bridge tests

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NX_DEAMON=false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,4 @@ vitest.config.*.timestamp*
8989
ssg
9090
.claude
9191
__mocks__/
92+
/.env

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
"postcss-url": "10.1.3",
204204
"prettier": "3.3.3",
205205
"prettier-eslint": "16.3.0",
206-
"publint": "^0.2.12",
206+
"publint": "^0.3.13",
207207
"qwik-nx": "^3.1.1",
208208
"react-refresh": "0.14.2",
209209
"rimraf": "^6.0.1",

packages/assemble-release-plan/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"dependencies": {
3939
"@changesets/errors": "^0.2.0",
40-
"@changesets/get-dependents-graph": "^2.1.2",
40+
"@changesets/get-dependents-graph": "^2.1.3",
4141
"@changesets/should-skip-package": "^0.1.1",
4242
"@changesets/types": "^6.0.0",
4343
"@manypkg/get-packages": "^1.1.3",

packages/bridge/bridge-react/__tests__/bridge.spec.tsx

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
screen,
88
waitFor,
99
} from '@testing-library/react';
10-
import { createContainer, getHtml, sleep } from './util';
10+
import { createContainer, getHtml } from './util';
1111

1212
describe('bridge', () => {
1313
let containerInfo: ReturnType<typeof createContainer>;
@@ -31,17 +31,28 @@ describe('bridge', () => {
3131
dom: containerInfo?.container,
3232
});
3333

34-
await sleep(200);
35-
expect(document.querySelector('#container')!.innerHTML).toContain(
36-
'<div>life cycle render</div>',
34+
await waitFor(
35+
() => {
36+
expect(document.querySelector('#container')?.innerHTML).toContain(
37+
'<div>life cycle render</div>',
38+
);
39+
},
40+
{ timeout: 2000 },
3741
);
3842

3943
lifeCycle.destroy({
4044
dom: containerInfo?.container,
4145
moduleName: 'test',
4246
});
4347

44-
expect(document.querySelector('#container')!.innerHTML).toContain('');
48+
await waitFor(
49+
() => {
50+
expect(
51+
(document.querySelector('#container')?.innerHTML || '').trim(),
52+
).toBe('');
53+
},
54+
{ timeout: 2000 },
55+
);
4556
});
4657

4758
it('createRemoteAppComponent', async () => {
@@ -66,9 +77,13 @@ describe('bridge', () => {
6677
);
6778
expect(getHtml(container)).toMatch('loading');
6879

69-
await sleep(200);
70-
expect(getHtml(container)).toMatch('life cycle render');
71-
expect(getHtml(container)).toMatch('hello world');
80+
await waitFor(
81+
() => {
82+
expect(getHtml(container)).toMatch('life cycle render');
83+
expect(getHtml(container)).toMatch('hello world');
84+
},
85+
{ timeout: 2000 },
86+
);
7287
});
7388

7489
it('createRemoteAppComponent and obtain ref property', async () => {
@@ -97,10 +112,14 @@ describe('bridge', () => {
97112
);
98113
expect(getHtml(container)).toMatch('loading');
99114

100-
await sleep(200);
101-
expect(getHtml(container)).toMatch('life cycle render');
102-
expect(getHtml(container)).toMatch('hello world');
103-
expect(ref.current).not.toBeNull();
115+
await waitFor(
116+
() => {
117+
expect(getHtml(container)).toMatch('life cycle render');
118+
expect(getHtml(container)).toMatch('hello world');
119+
expect(ref.current).not.toBeNull();
120+
},
121+
{ timeout: 2000 },
122+
);
104123
});
105124

106125
it('createRemoteAppComponent with custom createRoot prop', async () => {
@@ -131,7 +150,11 @@ describe('bridge', () => {
131150
const { container } = render(<RemoteComponent />);
132151
expect(getHtml(container)).toMatch('loading');
133152

134-
await sleep(200);
135-
expect(renderMock).toHaveBeenCalledTimes(1);
153+
await waitFor(
154+
() => {
155+
expect(renderMock).toHaveBeenCalledTimes(1);
156+
},
157+
{ timeout: 2000 },
158+
);
136159
});
137160
});

packages/enhanced/test/compiler-unit/container/HoistContainerReferencesPlugin.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @ts-nocheck
2+
13
import {
24
ModuleFederationPlugin,
35
dependencies,
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// @ts-nocheck
2+
/*
3+
* @jest-environment node
4+
*/
5+
6+
import { vol } from 'memfs';
7+
import SharePlugin from '../../../src/lib/sharing/SharePlugin';
8+
import {
9+
createRealCompiler,
10+
createMemfsCompilation,
11+
createNormalModuleFactory,
12+
} from '../../helpers/webpackMocks';
13+
14+
// Use memfs for fs inside this suite
15+
jest.mock('fs', () => require('memfs').fs);
16+
jest.mock('fs/promises', () => require('memfs').fs.promises);
17+
18+
// Mock child plugins to avoid deep integration
19+
jest.mock('../../../src/lib/sharing/ConsumeSharedPlugin', () => {
20+
return jest
21+
.fn()
22+
.mockImplementation((opts) => ({ options: opts, apply: jest.fn() }));
23+
});
24+
jest.mock('../../../src/lib/sharing/ProvideSharedPlugin', () => {
25+
return jest
26+
.fn()
27+
.mockImplementation((opts) => ({ options: opts, apply: jest.fn() }));
28+
});
29+
30+
import ConsumeSharedPlugin from '../../../src/lib/sharing/ConsumeSharedPlugin';
31+
import ProvideSharedPlugin from '../../../src/lib/sharing/ProvideSharedPlugin';
32+
33+
describe('SharePlugin smoke (memfs)', () => {
34+
beforeEach(() => {
35+
vol.reset();
36+
jest.clearAllMocks();
37+
});
38+
39+
it('applies child plugins with derived options', () => {
40+
// Create a tiny project in memfs
41+
vol.fromJSON({
42+
'/test-project/src/index.js': 'console.log("hello")',
43+
'/test-project/package.json': '{"name":"test","version":"1.0.0"}',
44+
'/test-project/node_modules/react/index.js': 'module.exports = {}',
45+
'/test-project/node_modules/lodash/index.js': 'module.exports = {}',
46+
});
47+
48+
const plugin = new SharePlugin({
49+
shareScope: 'default',
50+
shared: {
51+
react: '^17.0.0',
52+
lodash: { version: '4.17.21', singleton: true },
53+
'components/': { version: '1.0.0', eager: false },
54+
},
55+
});
56+
57+
const compiler = createRealCompiler('/test-project');
58+
expect(() => plugin.apply(compiler as any)).not.toThrow();
59+
60+
// Child plugins constructed
61+
expect(ConsumeSharedPlugin).toHaveBeenCalledTimes(1);
62+
expect(ProvideSharedPlugin).toHaveBeenCalledTimes(1);
63+
64+
// Each child plugin receives shareScope and normalized arrays
65+
const consumeOpts = (ConsumeSharedPlugin as jest.Mock).mock.calls[0][0];
66+
const provideOpts = (ProvideSharedPlugin as jest.Mock).mock.calls[0][0];
67+
expect(consumeOpts.shareScope).toBe('default');
68+
expect(Array.isArray(consumeOpts.consumes)).toBe(true);
69+
expect(provideOpts.shareScope).toBe('default');
70+
expect(Array.isArray(provideOpts.provides)).toBe(true);
71+
72+
// Simulate compilation lifecycle
73+
const compilation = createMemfsCompilation(compiler as any);
74+
const normalModuleFactory = createNormalModuleFactory();
75+
expect(() =>
76+
(compiler as any).hooks.thisCompilation.call(compilation, {
77+
normalModuleFactory,
78+
}),
79+
).not.toThrow();
80+
expect(() =>
81+
(compiler as any).hooks.compilation.call(compilation, {
82+
normalModuleFactory,
83+
}),
84+
).not.toThrow();
85+
86+
// Child plugin instances should be applied to the compiler
87+
const consumeInst = (ConsumeSharedPlugin as jest.Mock).mock.results[0]
88+
.value;
89+
const provideInst = (ProvideSharedPlugin as jest.Mock).mock.results[0]
90+
.value;
91+
expect(consumeInst.apply).toHaveBeenCalledWith(compiler);
92+
expect(provideInst.apply).toHaveBeenCalledWith(compiler);
93+
});
94+
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
/*
23
* @jest-environment node
34
*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
it('should be able to handle spaces in path to exposes', async () => {
2+
const { default: test1 } = await import('./test 1');
3+
const { default: test2 } = await import('./path with spaces/test-2');
4+
expect(test1()).toBe('test 1');
5+
expect(test2()).toBe('test 2');
6+
});

0 commit comments

Comments
 (0)