Skip to content

Commit 548c534

Browse files
fix: stabilize federated-css Playwright startup
1 parent 62d9dcc commit 548c534

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

federated-css/scripts/start-all.cjs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function run(cmd, args) {
1010

1111
async function main() {
1212
const reactConsumers = [
13-
{ dir: 'combination-of-4', port: 3001 },
14-
{ dir: 'combination-of-5', port: 3002 },
13+
{ dir: 'combination-of-4', port: 3001, serve: true },
14+
{ dir: 'combination-of-5', port: 3002, serve: true },
1515
{ dir: 'css-and-styled-component', port: 3003 },
1616
{ dir: 'css-module-and-jss', port: 3004 },
1717
{ dir: 'less-and-scss', port: 3005 },
@@ -22,19 +22,31 @@ async function main() {
2222
const exposes = [4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007];
2323

2424
const nextConsumers = [
25-
{ dir: 'combination-of-4', port: 8081 },
26-
{ dir: 'jss-and-tailwind-global', port: 8082 },
2725
{ dir: 'jss-css-and-tailwind-module', port: 8083 },
26+
{ dir: 'jss-and-tailwind-global', port: 8082 },
2827
{ dir: 'less-and-styled-component', port: 8084 },
28+
{ dir: 'combination-of-4', port: 8081 },
2929
];
3030

3131
const procs = [];
3232

33-
console.log('[federated-css] starting consumers-react (sequential dev servers)...');
34-
for (const { dir, port } of reactConsumers) {
33+
console.log('[federated-css] starting consumers-react (sequential servers)...');
34+
for (const { dir, port, serve } of reactConsumers) {
3535
const cwd = path.join('consumers-react', dir);
36-
const p = run('pnpm', ['-C', cwd, 'run', 'start']);
37-
procs.push(p);
36+
37+
if (serve) {
38+
console.log(`[federated-css] building consumers-react ${dir} for static serve...`);
39+
await new Promise((res, rej) => {
40+
const buildProc = run('pnpm', ['-C', cwd, 'run', 'build']);
41+
buildProc.on('exit', code => (code === 0 ? res() : rej(new Error(`build ${dir} failed`))));
42+
});
43+
const serveProc = run('pnpm', ['-C', cwd, 'run', 'serve']);
44+
procs.push(serveProc);
45+
} else {
46+
const devProc = run('pnpm', ['-C', cwd, 'run', 'start']);
47+
procs.push(devProc);
48+
}
49+
3850
await waitOn({ resources: [`http://localhost:${port}`], timeout: 480000, validateStatus: s => s >= 200 && s < 500 });
3951
console.log(`[federated-css] consumers-react ${dir} up at ${port}`);
4052
}

0 commit comments

Comments
 (0)