Skip to content

Commit

Permalink
build: add infrastructure to build local-variant package outputs to m…
Browse files Browse the repository at this point in the history
…ain build script

The main release build script now has the infrastructure needed to build
using the `local` bazel configuration. This is not yet used within the build
process but provides the base infrastructure to support local builds of the
packages in the future. `local` builds are package builds that contain file
path dependencies to the other built package archives in the workspace and
are used for local development and testing purposes only.
  • Loading branch information
clydin authored and dgp1130 committed Mar 12, 2024
1 parent c7b2085 commit 9f4e818
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions scripts/build-packages-dist.mts
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,28 @@ const defaultDistPath = join(projectDir, 'dist/releases');

/** Builds the release packages for NPM. */
export function performNpmReleaseBuild(): BuiltPackage[] {
return buildReleasePackages(defaultDistPath, /* isSnapshotBuild */ false);
return buildReleasePackages(defaultDistPath, /* config */ 'release');
}

/**
* Builds the release packages as snapshot build. This means that the current
* Git HEAD SHA is included in the version (for easier debugging and back tracing).
*/
export function performDefaultSnapshotBuild(): BuiltPackage[] {
return buildReleasePackages(defaultDistPath, /* isSnapshotBuild */ true);
return buildReleasePackages(defaultDistPath, /* config */'snapshot');
}

export function performLocalPackageBuild(): BuiltPackage[] {
return buildReleasePackages(defaultDistPath, /* config */'local');
}

/**
* Builds the release packages with the given compile mode and copies
* the package output into the given directory.
*/
function buildReleasePackages(distPath: string, isSnapshotBuild: boolean): BuiltPackage[] {
function buildReleasePackages(distPath: string, config: 'release' | 'snapshot' | 'local'): BuiltPackage[] {
console.log('######################################');
console.log(' Building release packages...');
console.log(` Building ${config} packages...`);
console.log('######################################');

// List of targets to build. e.g. "packages/angular/cli:npm_package"
Expand All @@ -69,7 +73,10 @@ function buildReleasePackages(distPath: string, isSnapshotBuild: boolean): Built
// Build with "--config=release" or `--config=snapshot` so that Bazel
// runs the workspace stamping script. The stamping script ensures that the
// version placeholder is populated in the release output.
const stampConfigArg = `--config=${isSnapshotBuild ? 'snapshot' : 'release'}`;
if (!['release', 'snapshot', 'local'].includes(config)) {
throw new Error('Invalid config value: ' + config);
}
const stampConfigArg = `--config=${config}`;

// Walk through each release package and clear previous "npm_package" outputs. This is
// a workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1219. We need to
Expand Down

0 comments on commit 9f4e818

Please sign in to comment.