Skip to content

packager

@evolve-framework/packager · v1.0.0

Builds a service into what a cloud deploys: a bundle for a Docker image, a zip for an AWS Lambda, a zip for an Azure Function app, or a zip of its Terraform. Each build bundles the service and its dependencies into ES modules for Node with source maps, so the deployed artifact needs no node_modules.

When to use

  • A service's build.ts script produces its deployment artifacts. Name each target once, and choose which to build with a command-line flag.
  • A service runs as a Lambda or an Azure Function, which deploys from a zip.
  • A service ships its own Terraform module as an archive beside its code.

Run it from inside a pnpm workspace: the source maps are rooted at the workspace, and a build stops if it cannot find pnpm-workspace.yaml.

Get started

  1. Install the package. It comes from the Evolve registry, which needs a one-time sign-in.

    pnpm add @evolve-framework/packager
    Requirements1
    @types/node>=22optional

For example:

import { buildAzureFunction, buildLambda, buildScripts, bundleTerraform } from "@evolve-framework/packager";
// build.ts: `node build.ts` builds every target, and `node build.ts --lambda`
// builds only that one.
await buildScripts({
lambda: () =>
buildLambda({
entryPoints: ["./src/lambda/handler.ts"],
outdir: "./dist/lambda",
archiveName: "dist/service-lambda.zip",
}),
"azure-function": () =>
buildAzureFunction({
srcDir: "./src/functions/azure",
outdir: "./dist/azure",
archiveName: "dist/service-azure-function.zip",
external: ["@azure/functions-core"],
}),
terraform: () => bundleTerraform({ archiveName: "dist/terraform.zip" }),
});

Entry points

@evolve-framework/packagerbuildScripts, which runs the targets named by command-line flags, and the builds: buildDocker, buildLambda, buildAzureFunction and bundleTerraform5 exports