mirror of
https://github.com/tutao/tutanota.git
synced 2025-10-19 07:53:47 +00:00

Building packages is a part of most build invocations. Our old approach during dev builds was to 1. Invoke npm once to run build-packages 2. Invoke npm per each package to run tsc. Unfortunately, npm is very slow. Additionally, the old approach was leading to tsc re-checking some packages multiple times because of dependencies between them. This would only worsen with time. In our new approach we 1. invoke tsc only once 2. try to avoid invoking npm as much as possible Unfortunately there is still one case where we invoke npx because we can't be sure that the location of node_modules/.bin is stable as we are sometimes used as a package. Without this we could reduce the time even further.
20 lines
621 B
JavaScript
20 lines
621 B
JavaScript
// For programmatic use please prefer "./packageBuilderFunctions"
|
|
// This is a wrapper mostly meant for npm.
|
|
|
|
import { Argument, program } from "commander"
|
|
import { buildPackages, buildRuntimePackages } from "./packageBuilderFunctions.js"
|
|
|
|
program.name("buildPackages").description("A script to invoke tsc -b on the right packages")
|
|
|
|
program
|
|
.addArgument(new Argument("type").choices(["runtime", "all"]))
|
|
.action(async (type) => {
|
|
if (type === "runtime") {
|
|
await buildRuntimePackages()
|
|
} else if (type === "all") {
|
|
await buildPackages()
|
|
} else {
|
|
throw new Error(`Unknown type ${type}`)
|
|
}
|
|
})
|
|
.parse()
|