Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions tests/integration/cli/mf-dev/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import fse, { existsSync } from 'fs-extra';
import { awaitFileExists } from 'test-helper';
import { expect, test } from 'vitest';

const distFolder = join(__dirname, 'dist');

describe('mf-dev', () => {
test('mf-dev --lib', async () => {
const fixturePath = join(__dirname);
const distFolder = join(__dirname, 'dist-mf0');
fse.removeSync(distFolder);
const distPath = join(distFolder, 'mf0', 'index.js');
const distPath = join(distFolder, 'index.js');

const childProcess = exec('npx rslib mf-dev --lib mf0', {
cwd: fixturePath,
Expand All @@ -25,9 +24,12 @@ describe('mf-dev', () => {

test('mf-dev --lib multiple', async () => {
const fixturePath = join(__dirname);
fse.removeSync(distFolder);
const distPath1 = join(distFolder, 'mf1', 'index.js');
const distPath2 = join(distFolder, 'mf2', 'index.js');
const distFolder1 = join(__dirname, 'dist-mf1');
const distFolder2 = join(__dirname, 'dist-mf2');
fse.removeSync(distFolder1);
fse.removeSync(distFolder2);
const distPath1 = join(distFolder1, 'index.js');
const distPath2 = join(distFolder2, 'index.js');

const childProcess = exec('npx rslib mf-dev --lib mf1 --lib mf2', {
cwd: fixturePath,
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/cli/mf-dev/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export default defineConfig({
format: 'mf',
output: {
distPath: {
root: 'dist/mf0',
root: 'dist-mf0',
},
},
},
{
format: 'mf',
output: {
distPath: {
root: 'dist/mf1',
root: 'dist-mf1',
},
},
},
Expand All @@ -24,7 +24,7 @@ export default defineConfig({
format: 'mf',
output: {
distPath: {
root: 'dist/mf2',
root: 'dist-mf2',
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/server/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe('server config', async () => {
const fixturePath = join(__dirname, 'mf-dev');
const distPath = join(fixturePath, 'dist');
const rsbuildConfigFile = join(distPath, '.rsbuild/rsbuild.config.mjs');
const doneFile = join(distPath, 'done.txt');

fse.removeSync(distPath);

const childProcess = exec('npx rslib mf-dev', {
Expand All @@ -30,7 +32,7 @@ describe('server config', async () => {
},
});

await awaitFileExists(rsbuildConfigFile);
await awaitFileExists(doneFile);

const rsbuildConfigContent = await fse.readFile(rsbuildConfigFile, 'utf-8');
expect(rsbuildConfigContent).toContain('open: true');
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/server/mf-dev/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import fs from 'node:fs';
import { join } from 'node:path';
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
import type { RsbuildPlugin } from '@rsbuild/core';
import { defineConfig } from '@rslib/core';

const distPath = join(__dirname, 'dist');

const afterDevCompileDonePlugin: RsbuildPlugin = {
name: 'dev-done',
setup(api) {
api.onDevCompileDone(() => {
fs.writeFileSync(join(distPath, 'done.txt'), 'done');
});
},
};

export default defineConfig({
lib: [
{
Expand All @@ -15,5 +29,6 @@ export default defineConfig({
pluginModuleFederation({
name: 'test',
}),
afterDevCompileDonePlugin,
],
});
Loading