The rule mesh-build-node and build-agent each keep their own copy of: x.js is started by x.serve.mjs beside it; other languages get none (ADR 0193).
25 lines
1.0 KiB
Go
25 lines
1.0 KiB
Go
package buildstep
|
|
|
|
import "strings"
|
|
|
|
// LauncherSuffix is what a TypeScript entrypoint's launcher is called beside it: index.js is started as
|
|
// index.serve.mjs (novox/hq ADR 0193), an ES module by its own extension whatever the bundle's package.json says.
|
|
const LauncherSuffix = ".serve.mjs"
|
|
|
|
// Launchers are the launchers a bundle's build writes, by entrypoint, relative to the bundle's root: for TypeScript
|
|
// every entrypoint `x.js` is started by `x.serve.mjs` beside it; an entrypoint that is not JavaScript and every other
|
|
// language, whose build is already executable, get none. The one rule mesh-build-node, build-agent and the controller
|
|
// share (R4e), so the name a build writes is the name a reader expects.
|
|
func Launchers(language string, entrypoints []string) map[string]string {
|
|
out := map[string]string{}
|
|
if language != "typescript" {
|
|
return out
|
|
}
|
|
for _, entry := range entrypoints {
|
|
if strings.HasSuffix(entry, ".js") {
|
|
out[entry] = strings.TrimSuffix(entry, ".js") + LauncherSuffix
|
|
}
|
|
}
|
|
return out
|
|
}
|