Merge branch 'main' into dev
* main: web: improve build speeds even moar!!!!!! (#8954)
This commit is contained in:
@ -55,15 +55,15 @@ for (const [source, rawdest, strip] of otherFiles) {
|
|||||||
|
|
||||||
// This starts the definitions used for esbuild: Our targets, our arguments, the function for running a build, and three
|
// This starts the definitions used for esbuild: Our targets, our arguments, the function for running a build, and three
|
||||||
// options for building: watching, building, and building the proxy.
|
// options for building: watching, building, and building the proxy.
|
||||||
|
// Ordered by largest to smallest interface to build even faster
|
||||||
const interfaces = [
|
const interfaces = [
|
||||||
["polyfill/poly.ts", "."],
|
|
||||||
["standalone/loading/index.ts", "standalone/loading"],
|
|
||||||
["flow/FlowInterface.ts", "flow"],
|
|
||||||
["user/UserInterface.ts", "user"],
|
|
||||||
["enterprise/rac/index.ts", "enterprise/rac"],
|
|
||||||
["standalone/api-browser/index.ts", "standalone/api-browser"],
|
|
||||||
["admin/AdminInterface/AdminInterface.ts", "admin"],
|
["admin/AdminInterface/AdminInterface.ts", "admin"],
|
||||||
|
["user/UserInterface.ts", "user"],
|
||||||
|
["flow/FlowInterface.ts", "flow"],
|
||||||
|
["standalone/api-browser/index.ts", "standalone/api-browser"],
|
||||||
|
["enterprise/rac/index.ts", "enterprise/rac"],
|
||||||
|
["standalone/loading/index.ts", "standalone/loading"],
|
||||||
|
["polyfill/poly.ts", "."],
|
||||||
];
|
];
|
||||||
|
|
||||||
const baseArgs = {
|
const baseArgs = {
|
||||||
@ -80,29 +80,32 @@ const baseArgs = {
|
|||||||
format: "esm",
|
format: "esm",
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildAuthentik(interfaces) {
|
async function buildOneSource(source, dest) {
|
||||||
for (const [source, dest] of interfaces) {
|
const DIST = path.join(__dirname, "./dist", dest);
|
||||||
const DIST = path.join(__dirname, "./dist", dest);
|
console.log(`[${new Date(Date.now()).toISOString()}] Starting build for target ${source}`);
|
||||||
console.log(`[${new Date(Date.now()).toISOString()}] Starting build for target ${source}`);
|
|
||||||
try {
|
try {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
esbuild.buildSync({
|
await esbuild.build({
|
||||||
...baseArgs,
|
...baseArgs,
|
||||||
entryPoints: [`./src/${source}`],
|
entryPoints: [`./src/${source}`],
|
||||||
outdir: DIST,
|
outdir: DIST,
|
||||||
});
|
});
|
||||||
const end = Date.now();
|
const end = Date.now();
|
||||||
console.log(
|
console.log(
|
||||||
`[${new Date(end).toISOString()}] Finished build for target ${source} in ${Date.now() - start}ms`,
|
`[${new Date(end).toISOString()}] Finished build for target ${source} in ${
|
||||||
);
|
Date.now() - start
|
||||||
} catch (exc) {
|
}ms`,
|
||||||
console.error(
|
);
|
||||||
`[${new Date(Date.now()).toISOString()}] Failed to build ${source}: ${exc}`,
|
} catch (exc) {
|
||||||
);
|
console.error(`[${new Date(Date.now()).toISOString()}] Failed to build ${source}: ${exc}`);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function buildAuthentik(interfaces) {
|
||||||
|
await Promise.allSettled(interfaces.map(([source, dest]) => buildOneSource(source, dest)));
|
||||||
|
}
|
||||||
|
|
||||||
let timeoutId = null;
|
let timeoutId = null;
|
||||||
function debouncedBuild() {
|
function debouncedBuild() {
|
||||||
if (timeoutId !== null) {
|
if (timeoutId !== null) {
|
||||||
@ -138,9 +141,11 @@ if (process.argv.length > 2 && (process.argv[2] === "-w" || process.argv[2] ===
|
|||||||
});
|
});
|
||||||
} else if (process.argv.length > 2 && (process.argv[2] === "-p" || process.argv[2] === "--proxy")) {
|
} else if (process.argv.length > 2 && (process.argv[2] === "-p" || process.argv[2] === "--proxy")) {
|
||||||
// There's no watch-for-proxy, sorry.
|
// There's no watch-for-proxy, sorry.
|
||||||
buildAuthentik(interfaces.slice(0, 2));
|
await buildAuthentik(
|
||||||
|
interfaces.filter(([_, dest]) => ["standalone/loading", "."].includes(dest)),
|
||||||
|
);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} else {
|
} else {
|
||||||
// And the fallback: just build it.
|
// And the fallback: just build it.
|
||||||
buildAuthentik(interfaces);
|
await buildAuthentik(interfaces);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user