Skip to content

Commit 6b3e28e

Browse files
authored
fix: devServer exception (#12547)
When executing `dev-server.mjs` with ui5nps, ui5nps expect that this file is used as a module and expects _ui5main function to exists.
1 parent 33b962f commit 6b3e28e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/tools/lib/dev-server/dev-server.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from "fs/promises";
22
import { createServer } from 'vite';
33
import yargs from 'yargs';
4-
import { hideBin } from 'yargs/helpers';
4+
import { hideBin } from 'yargs/helpers';
55

66
const argv = yargs(hideBin(process.argv))
77
.alias("c", "config")
@@ -28,15 +28,15 @@ const rmPortFile = async () => {
2828
// exit handler must be sync
2929
try {
3030
await fs.rm(".dev-server-port");
31-
} catch (e) {}
31+
} catch (e) { }
3232
process.exit();
3333
}
3434

3535
["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException", "SIGTERM"].forEach((eventType) => {
3636
process.on(eventType, rmPortFile);
3737
});
3838

39-
(async () => {
39+
async function start() {
4040
let retries = 10;
4141
let port = 8080;
4242
while (retries--) {
@@ -63,4 +63,12 @@ const rmPortFile = async () => {
6363
// no error normal exit
6464
// process.exit();
6565
}
66-
})();
66+
};
67+
68+
if (import.meta.url === `file://${process.argv[1]}`) {
69+
start(process.argv)
70+
}
71+
72+
export default {
73+
_ui5mainFn: start
74+
}

0 commit comments

Comments
 (0)