diff --git a/test/fixtures/module-federation-config/webpack.plugin.js b/test/fixtures/module-federation-config/webpack.plugin.js new file mode 100644 index 0000000000..325ff35cd2 --- /dev/null +++ b/test/fixtures/module-federation-config/webpack.plugin.js @@ -0,0 +1,24 @@ +'use strict'; + +const ModuleFederationPlugin = require('webpack').container + .ModuleFederationPlugin; + +module.exports = { + mode: 'development', + target: 'node', + context: __dirname, + entry: ['./entry1.js'], + plugins: [ + new ModuleFederationPlugin({ + name: 'app1', + library: { type: 'var', name: 'app1' }, + filename: 'remoteEntry.js', + exposes: { + './entry1': './entry1', + }, + }), + ], + infrastructureLogging: { + level: 'warn', + }, +}; diff --git a/test/integration/ModuleFederation.test.js b/test/integration/ModuleFederation.test.js index 678f2758c7..bf4faa5bbf 100644 --- a/test/integration/ModuleFederation.test.js +++ b/test/integration/ModuleFederation.test.js @@ -7,6 +7,13 @@ const simpleConfig = require('../fixtures/module-federation-config/webpack.confi const objectEntryConfig = require('../fixtures/module-federation-config/webpack.object-entry.config'); const multiConfig = require('../fixtures/module-federation-config/webpack.multi.config'); const port = require('../ports-map').ModuleFederation; +const isWebpack5 = require('../helpers/isWebpack5'); + +let pluginConfig; + +if (isWebpack5) { + pluginConfig = require('../fixtures/module-federation-config/webpack.plugin'); +} describe('module federation', () => { describe.each([ @@ -52,4 +59,25 @@ describe('module federation', () => { }); } }); + + (isWebpack5 ? describe : describe.skip)('use plugin', () => { + let server; + let req; + + beforeAll((done) => { + server = testServer.start(pluginConfig, { port }, done); + req = request(server.app); + }); + + afterAll(testServer.close); + + it('should contain hot script', async () => { + const { statusCode } = await req.get('/remoteEntry.js'); + expect(statusCode).toEqual(200); + await req.get('/main.js').expect(200, /webpack\/hot\/dev-server\.js/); + await req + .get('/remoteEntry.js') + .expect(200, /webpack\/hot\/dev-server\.js/); + }); + }); });