diff --git a/bundle/package.json b/bundle/package.json
index fbb39042..c62d6c53 100644
--- a/bundle/package.json
+++ b/bundle/package.json
@@ -5,13 +5,8 @@
"main": "src/start.js",
"scripts": {
"setup": "cd ../util && npm --production=false i && cd ../api && npm --production=false i && cd ../cdn && npm --production=false i && cd ../gateway && npm --production=false i && cd ../bundle/ && npm --production=false i && npm run build",
- "build": "npm run build:util && npm run build:api && npm run build:cdn && npm run build:gateway && npm run build:bundle",
- "postinstall": "ts-patch install -s",
- "build:bundle": "swc src --out-dir dist",
- "build:util": "cd ../util/ && npm run build",
- "build:api": "cd ../api/ && npm run build",
- "build:cdn": "cd ../cdn/ && npm run build",
- "build:gateway": "cd ../gateway/ && npm run build",
+ "build": "node scripts/build.js",
+ "build:bundle": "npx swc src --out-dir dist",
"start": "npm run build && npm run start:bundle",
"start:bundle": "node dist/start.js",
"test": "echo \"Error: no test specified\" && exit 1"
diff --git a/bundle/scripts/build.js b/bundle/scripts/build.js
new file mode 100644
index 00000000..c5f9149c
--- /dev/null
+++ b/bundle/scripts/build.js
@@ -0,0 +1,37 @@
+const { spawn } = require("child_process");
+const path = require("path");
+const { performance } = require("perf_hooks");
+
+let parts = "util,api,cdn,gateway,bundle".split(",");
+
+// because npm run is slow we directly get the build script of the package.json script
+
+function buildPackage(dir) {
+ const element = path.basename(dir);
+ const swcBin = path.join(dir, "node_modules", "@swc", "cli", "lib", "swc", "index.js");
+
+ const child = spawn("node", `${swcBin} src --out-dir dist --sync`.split(" "), {
+ cwd: dir,
+ env: process.env,
+ shell: true,
+ });
+ function log(data) {
+ console.log(`[${element}]`.padEnd(10, " ") + data.toString().slice(0, -1));
+ }
+ child.stdout.on("data", log);
+ child.stderr.on("data", log);
+ child.on("error", (err) => console.error(element, err));
+ return child;
+}
+
+// util needs to be compiled first as the others require it
+
+const start = performance.now();
+
+for (const part of parts) {
+ buildPackage(path.join(__dirname, "..", "..", part));
+}
+
+process.on("exit", () => {
+ console.log("[Build] took " + Math.round(performance.now() - start) + "ms");
+});
diff --git a/bundle/src/build.js b/bundle/src/build.js
deleted file mode 100644
index b893d5ee..00000000
--- a/bundle/src/build.js
+++ /dev/null
@@ -1,18 +0,0 @@
-const { exec, spawn } = require("child_process");
-const { exitCode } = require("process");
-
-let parts = "api,cdn,gateway,util,bundle".split(",");
-parts.forEach(element => {
- // exec(`npm --prefix ../${element} run build`, (error, stdout, stderr) => {
- // if (error) {
- // console.log(`error: ${error.message}`);
- // return;
- // }
- // if (stderr) {
- // console.log(`stderr: ${stderr}`);
- // return;
- // }
- // console.log(`stdout: ${stdout}`);
- // });
- spawn("npm", ["run", "build"], {cwd: `../${element}`});
-});
\ No newline at end of file
diff --git a/bundle/tsconfig.tsbuildinfo b/bundle/tsconfig.tsbuildinfo
deleted file mode 100644
index 44ebd120..00000000
--- a/bundle/tsconfig.tsbuildinfo
+++ /dev/null
@@ -1 +0,0 @@
-{"version":"4.4.3"}
\ No newline at end of file
|