From e7b8758a11723bdd4d6e4ef31e3150f989cdab74 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 23 Aug 2024 17:54:08 +0800 Subject: [PATCH] fix(mf): should compile `@module-federation/sdk` (#3270) --- e2e/cases/module-federation/index.test.ts | 72 ++++++++++--------- packages/core/src/plugins/moduleFederation.ts | 1 + 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/e2e/cases/module-federation/index.test.ts b/e2e/cases/module-federation/index.test.ts index 05bc61344d..c853b8b506 100644 --- a/e2e/cases/module-federation/index.test.ts +++ b/e2e/cases/module-federation/index.test.ts @@ -93,45 +93,47 @@ rspackOnlyTest( }, ); -// TODO: fix this test -test.fail('should transform module federation runtime with SWC', async () => { - writeButtonCode(); +rspackOnlyTest( + 'should transform module federation runtime with SWC', + async () => { + writeButtonCode(); - const remotePort = await getRandomPort(); + const remotePort = await getRandomPort(); - process.env.REMOTE_PORT = remotePort.toString(); + process.env.REMOTE_PORT = remotePort.toString(); - await expect( - build({ - cwd: remote, - rsbuildConfig: { - output: { - overrideBrowserslist: ['Chrome >= 51'], - }, - performance: { - chunkSplit: { - strategy: 'all-in-one', + await expect( + build({ + cwd: remote, + rsbuildConfig: { + output: { + overrideBrowserslist: ['Chrome >= 51'], }, + performance: { + chunkSplit: { + strategy: 'all-in-one', + }, + }, + plugins: [pluginCheckSyntax()], }, - plugins: [pluginCheckSyntax()], - }, - }), - ).resolves.toBeTruthy(); - - await expect( - build({ - cwd: host, - rsbuildConfig: { - output: { - overrideBrowserslist: ['Chrome >= 51'], - }, - performance: { - chunkSplit: { - strategy: 'all-in-one', + }), + ).resolves.toBeTruthy(); + + await expect( + build({ + cwd: host, + rsbuildConfig: { + output: { + overrideBrowserslist: ['Chrome >= 51'], }, + performance: { + chunkSplit: { + strategy: 'all-in-one', + }, + }, + plugins: [pluginCheckSyntax()], }, - plugins: [pluginCheckSyntax()], - }, - }), - ).resolves.toBeTruthy(); -}); + }), + ).resolves.toBeTruthy(); + }, +); diff --git a/packages/core/src/plugins/moduleFederation.ts b/packages/core/src/plugins/moduleFederation.ts index 44d0fb8301..56bad617d5 100644 --- a/packages/core/src/plugins/moduleFederation.ts +++ b/packages/core/src/plugins/moduleFederation.ts @@ -130,6 +130,7 @@ export function pluginModuleFederation(): RsbuildPlugin { // adding to include and let SWC transform it config.source.include = [ ...(config.source.include || []), + /@module-federation[\\/]sdk/, /@module-federation[\\/]runtime/, ]; });