Skip to content

Commit 74e4297

Browse files
authored
test: use webpack5 and ModuleFederationPlugin (#2853)
1 parent a16bbee commit 74e4297

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const ModuleFederationPlugin = require('webpack').container
4+
.ModuleFederationPlugin;
5+
6+
module.exports = {
7+
mode: 'development',
8+
target: 'node',
9+
context: __dirname,
10+
entry: ['./entry1.js'],
11+
plugins: [
12+
new ModuleFederationPlugin({
13+
name: 'app1',
14+
library: { type: 'var', name: 'app1' },
15+
filename: 'remoteEntry.js',
16+
exposes: {
17+
'./entry1': './entry1',
18+
},
19+
}),
20+
],
21+
infrastructureLogging: {
22+
level: 'warn',
23+
},
24+
};

test/integration/ModuleFederation.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ const simpleConfig = require('../fixtures/module-federation-config/webpack.confi
77
const objectEntryConfig = require('../fixtures/module-federation-config/webpack.object-entry.config');
88
const multiConfig = require('../fixtures/module-federation-config/webpack.multi.config');
99
const port = require('../ports-map').ModuleFederation;
10+
const isWebpack5 = require('../helpers/isWebpack5');
11+
12+
let pluginConfig;
13+
14+
if (isWebpack5) {
15+
pluginConfig = require('../fixtures/module-federation-config/webpack.plugin');
16+
}
1017

1118
describe('module federation', () => {
1219
describe.each([
@@ -52,4 +59,25 @@ describe('module federation', () => {
5259
});
5360
}
5461
});
62+
63+
(isWebpack5 ? describe : describe.skip)('use plugin', () => {
64+
let server;
65+
let req;
66+
67+
beforeAll((done) => {
68+
server = testServer.start(pluginConfig, { port }, done);
69+
req = request(server.app);
70+
});
71+
72+
afterAll(testServer.close);
73+
74+
it('should contain hot script', async () => {
75+
const { statusCode } = await req.get('/remoteEntry.js');
76+
expect(statusCode).toEqual(200);
77+
await req.get('/main.js').expect(200, /webpack\/hot\/dev-server\.js/);
78+
await req
79+
.get('/remoteEntry.js')
80+
.expect(200, /webpack\/hot\/dev-server\.js/);
81+
});
82+
});
5583
});

0 commit comments

Comments
 (0)