Skip to content

Commit

Permalink
build: update angular shared dev-infra code (angular#26530)
Browse files Browse the repository at this point in the history
* build: update angular shared dev-infra code

Updates the dev-infra packages and accounts for breaking
changes to stamping, linker/optimization.

* build: update bazel setup

Note that Renovate did not update the `WORKSPACE` file, and
we needed to update it ourselves.
  • Loading branch information
devversion authored Jan 31, 2023
1 parent 0e35cc0 commit d181eb9
Show file tree
Hide file tree
Showing 14 changed files with 463 additions and 624 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/assistant-to-the-branch-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
with:
persist-credentials: false
- uses: angular/dev-infra/github-actions/branch-manager@0a49ed85541ecbb28a0e19eefce7a874c1eaab5e
- uses: angular/dev-infra/github-actions/branch-manager@fa428ee0accc999f051008f0daa5651ba2728c2b
with:
angular-robot-key: ${{ secrets.ANGULAR_ROBOT_PRIVATE_KEY }}
4 changes: 2 additions & 2 deletions .github/workflows/build-dev-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2.0.0
- uses: ./.github/actions/yarn-install

- uses: angular/dev-infra/github-actions/setup-bazel-remote-exec@0a49ed85541ecbb28a0e19eefce7a874c1eaab5e
- uses: angular/dev-infra/github-actions/setup-bazel-remote-exec@fa428ee0accc999f051008f0daa5651ba2728c2b
with:
bazelrc: ./.bazelrc.user

Expand All @@ -34,7 +34,7 @@ jobs:
# the number of concurrent actions is determined based on the host resources.
- run: bazel build //src/dev-app:web_package --symlink_prefix=dist/ --jobs=32

- uses: angular/dev-infra/github-actions/deploy-previews/pack-and-upload-artifact@0a49ed85541ecbb28a0e19eefce7a874c1eaab5e
- uses: angular/dev-infra/github-actions/deploy-previews/pack-and-upload-artifact@fa428ee0accc999f051008f0daa5651ba2728c2b
with:
workflow-artifact-name: 'dev-app'
pull-number: '${{github.event.pull_request.number}}'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-dev-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
npx -y firebase-tools@latest target:clear --project ${{env.PREVIEW_PROJECT}} hosting dev-app
npx -y firebase-tools@latest target:apply --project ${{env.PREVIEW_PROJECT}} hosting dev-app ${{env.PREVIEW_SITE}}
- uses: angular/dev-infra/github-actions/deploy-previews/upload-artifacts-to-firebase@0a49ed85541ecbb28a0e19eefce7a874c1eaab5e
- uses: angular/dev-infra/github-actions/deploy-previews/upload-artifacts-to-firebase@fa428ee0accc999f051008f0daa5651ba2728c2b
with:
github-token: '${{secrets.GITHUB_TOKEN}}'
workflow-artifact-name: 'dev-app'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dev-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- uses: angular/dev-infra/github-actions/commit-message-based-labels@0a49ed85541ecbb28a0e19eefce7a874c1eaab5e
- uses: angular/dev-infra/github-actions/commit-message-based-labels@fa428ee0accc999f051008f0daa5651ba2728c2b
with:
angular-robot-key: ${{ secrets.ANGULAR_ROBOT_PRIVATE_KEY }}
post_approval_changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- uses: angular/dev-infra/github-actions/post-approval-changes@0a49ed85541ecbb28a0e19eefce7a874c1eaab5e
- uses: angular/dev-infra/github-actions/post-approval-changes@fa428ee0accc999f051008f0daa5651ba2728c2b
with:
angular-robot-key: ${{ secrets.ANGULAR_ROBOT_PRIVATE_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/google-internal-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0
- uses: angular/dev-infra/github-actions/google-internal-tests@0a49ed85541ecbb28a0e19eefce7a874c1eaab5e
- uses: angular/dev-infra/github-actions/google-internal-tests@fa428ee0accc999f051008f0daa5651ba2728c2b
with:
run-tests-guide-url: http://go/angular-material-presubmit
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lock-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
lock_closed:
runs-on: ubuntu-latest
steps:
- uses: angular/dev-infra/github-actions/lock-closed@0a49ed85541ecbb28a0e19eefce7a874c1eaab5e
- uses: angular/dev-infra/github-actions/lock-closed@fa428ee0accc999f051008f0daa5651ba2728c2b
with:
lock-bot-key: ${{ secrets.LOCK_BOT_PRIVATE_KEY }}
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Add NodeJS rules
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "2b2004784358655f334925e7eadc7ba80f701144363df949b3293e1ae7a2fb7b",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.4.0/rules_nodejs-5.4.0.tar.gz"],
sha256 = "dcc55f810142b6cf46a44d0180a5a7fb923c04a5061e2e8d8eb05ccccc60864b",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.0/rules_nodejs-5.8.0.tar.gz"],
)

# Add sass rules
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,27 @@
"@angular-devkit/core": "^15.1.0",
"@angular-devkit/schematics": "^15.1.0",
"@angular/bazel": "15.0.4",
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#1fd144d9f9db6a6cfe3e2617c4fc70e119a400cb",
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#57ce1b4bb7ab323c5c7610081a93148796b4ae81",
"@angular/cli": "^15.1.0",
"@angular/compiler-cli": "^15.1.0",
"@angular/localize": "^15.1.0",
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#757a386a63e960c4006efd26482f0d52dd0a1604",
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#ecad30aeac0b82fc1d2a8b9833b3f9c04311cedc",
"@angular/platform-browser-dynamic": "^15.1.0",
"@angular/platform-server": "^15.1.0",
"@angular/router": "^15.1.0",
"@axe-core/webdriverjs": "^4.3.2",
"@babel/core": "^7.16.12",
"@bazel/bazelisk": "1.12.1",
"@bazel/buildifier": "5.1.0",
"@bazel/concatjs": "5.7.2",
"@bazel/esbuild": "5.7.2",
"@bazel/buildifier": "6.0.1",
"@bazel/concatjs": "5.7.3",
"@bazel/esbuild": "5.7.3",
"@bazel/ibazel": "0.16.2",
"@bazel/jasmine": "5.7.2",
"@bazel/protractor": "5.7.2",
"@bazel/rollup": "5.7.2",
"@bazel/runfiles": "5.7.2",
"@bazel/terser": "5.7.2",
"@bazel/worker": "5.7.2",
"@bazel/jasmine": "5.7.3",
"@bazel/protractor": "5.7.3",
"@bazel/rollup": "5.7.3",
"@bazel/runfiles": "5.7.3",
"@bazel/terser": "5.7.3",
"@bazel/worker": "5.7.3",
"@firebase/app-types": "^0.7.0",
"@material/animation": "15.0.0-canary.684e33d25.0",
"@material/auto-init": "15.0.0-canary.684e33d25.0",
Expand Down Expand Up @@ -170,7 +170,7 @@
"date-fns": "^2.28.0",
"dgeni": "^0.4.14",
"dgeni-packages": "^0.29.5",
"esbuild": "^0.14.14",
"esbuild": "^0.17.5",
"firebase-tools": "^9.2.1",
"fs-extra": "^9.0.1",
"glob": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NPM_PACKAGE_SUBSTITUTIONS = {
# Version of `tslib`
"0.0.0-TSLIB": TSLIB_PACKAGE_VERSION,
# Version of the local package being built, generated via the `--workspace_status_command` flag.
"0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}",
"0.0.0-PLACEHOLDER": "{STABLE_PROJECT_VERSION}",
# Version of `rxjs`
"0.0.0-RXJS": RXJS_PACKAGE_VERSION,
}
Expand Down
11 changes: 0 additions & 11 deletions scripts/build-packages-dist.mts
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,6 @@ function buildReleasePackages(distPath: string, isSnapshotBuild: boolean): Built
// version placeholder is populated in the release output.
const stampConfigArg = `--config=${isSnapshotBuild ? 'snapshot-build' : 'release'}`;

// 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
// do this to ensure that the version placeholders are properly populated.
packageNames.forEach(pkgName => {
const outputPath = getBazelOutputPath(pkgName);
if (sh.test('-d', outputPath)) {
sh.chmod('-R', 'u+w', outputPath);
sh.rm('-rf', outputPath);
}
});

exec(`${bazelCmd} build ${stampConfigArg} ${targets.join(' ')}`);

// Delete the distribution directory so that the output is guaranteed to be clean. Re-create
Expand Down
11 changes: 9 additions & 2 deletions scripts/create-legacy-tests-bundle.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import {createLinkerEsbuildPlugin} from '@angular/build-tooling/shared-scripts/angular-linker/esbuild-plugin.mjs';
import {createEsbuildAngularOptimizePlugin} from '@angular/build-tooling/shared-scripts/angular-optimization/esbuild-plugin.mjs';
import child_process from 'child_process';
import esbuild from 'esbuild';
import fs from 'fs';
Expand Down Expand Up @@ -48,7 +48,14 @@ async function main() {
await compileProjectWithNgtsc();

const specEntryPointFile = await createEntryPointSpecFile();
const esbuildLinkerPlugin = await createLinkerEsbuildPlugin(/fesm2020/, false);
const esbuildLinkerPlugin = await createEsbuildAngularOptimizePlugin({
enableLinker: {
filterPaths: /fesm2020/,
linkerOptions: {
linkerJitMode: true,
},
},
});
const esbuildResolvePlugin = await createResolveEsbuildPlugin();

const result = await esbuild.build({
Expand Down
2 changes: 1 addition & 1 deletion tools/angular/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ esbuild_config(
name = "esbuild_config",
config_file = "esbuild.config.mjs",
deps = [
"@npm//@angular/build-tooling/shared-scripts/angular-linker:js_lib",
"@npm//@angular/build-tooling/shared-scripts/angular-optimization:js_lib",
],
)

Expand Down
16 changes: 12 additions & 4 deletions tools/angular/esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@
* found in the LICENSE file at https://angular.io/license
*/

import {createLinkerEsbuildPlugin} from '@angular/build-tooling/shared-scripts/angular-linker/esbuild-plugin.mjs';
import {createEsbuildAngularOptimizePlugin} from '@angular/build-tooling/shared-scripts/angular-optimization/esbuild-plugin.mjs';

export default {
// Note: We support `.mjs` here as this is the extension used by Angular APF packages.
resolveExtensions: ['.mjs', '.js'],
format: 'esm',
plugins: [
// Only run the linker on `fesm2020/` bundles. This should not have an effect on
// the bundle output, but helps speeding up ESBuild when it visits other modules.
await createLinkerEsbuildPlugin(/fesm2020/),
await createEsbuildAngularOptimizePlugin({
enableLinker: {
// Only run the linker on `fesm2020/` bundles. This should not have an effect on
// the bundle output, but helps speeding up ESBuild when it visits other modules.
filterPaths: /fesm2020/,
linkerOptions: {
// We enable JIT mode as unit tests may need it for overriding.
linkerJitMode: true,
},
},
}),
],
};
Loading

0 comments on commit d181eb9

Please sign in to comment.