Skip to content

fix(ng-add): syntax error due to ES2020 being used for ng-add with NodeJS 12.x #23744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
node_modules

integration/ng-update-v13/.angular
integration/ng-update-v13/node_modules

integration/ng-add/.angular
integration/ng-add/node_modules
11 changes: 5 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# http://yaml-online-parser.appspot.com/

var_1: &docker_image circleci/node:16.10.0
var_2: &docker-firefox-image circleci/node:16.10.0-browsers
var_2: &docker-browser-image circleci/node:16.10.0-browsers

# **Note**: When updating the beginning of the cache key, also update the cache key to match
# the new cache key prefix. This allows us to take advantage of CircleCI's fallback caching.
Expand Down Expand Up @@ -439,7 +439,7 @@ jobs:
# ----------------------------------------------------------------------------
snapshot_tests_local_browsers:
docker:
- image: *docker-firefox-image
- image: *docker-browser-image
resource_class: xlarge
environment:
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
Expand All @@ -459,7 +459,8 @@ jobs:
# Job that runs all Bazel integration tests.
# ----------------------------------------------------------------------------
integration_tests:
<<: *job_defaults
docker:
- image: *docker-browser-image
resource_class: xlarge
environment:
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
Expand All @@ -472,9 +473,7 @@ jobs:
- *setup_bazel_binary

- run: yarn integration-tests:partial-ivy
# TODO: Re-enable when there are integration tests that should run with Ivy.
# Currently this command fails as there are no tests.
# - run: yarn integration-tests
- run: yarn integration-tests
- run:
name: Running size integration tests (failures are reported in Slack only).
command: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
node_modules
/bower_components

# Angular CLI project cache
.angular/

# Dart
/.pub
/.packages
Expand Down
28 changes: 28 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Add NodeJS rules
http_archive(
name = "build_bazel_rules_nodejs",
patches = ["//tools:multiple-node-versions.patch"],
sha256 = "3635797a96c7bfcd0d265dacd722a07335e64d6ded9834af8d3f1b7ba5a25bba",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.3.0/rules_nodejs-4.3.0.tar.gz"],
)
Expand All @@ -34,6 +35,19 @@ http_archive(
],
)

http_archive(
name = "rules_pkg",
sha256 = "a89e203d3cf264e564fcb96b6e06dd70bc0557356eb48400ce4b5d97c2c3720d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.5.1/rules_pkg-0.5.1.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.5.1/rules_pkg-0.5.1.tar.gz",
],
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()
Expand All @@ -47,13 +61,27 @@ node_repositories(
package_json = ["//:package.json"],
)

load("@build_bazel_rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

# This call sets up another repository for Node 12.x used in integration tests. This
# allows us to ensure our schematic code works with NodeJS v12 LTS. The Node v12.x
# version is not fetched unless explicitly requested by the tests.
nodejs_register_toolchains(
name = "node12",
node_version = "12.20.0",
)

load("//tools:integration.bzl", "create_npm_package_archive_build_file")

yarn_install(
name = "npm",
# We add the postinstall patches file here so that Yarn will rerun whenever
# the file is modified.
data = [
"//:tools/postinstall/apply-patches.js",
],
# Add archive targets for some NPM packages that are needed in integration tests.
manual_build_file_contents = create_npm_package_archive_build_file(),
package_json = "//:package.json",
quiet = False,
yarn_lock = "//:yarn.lock",
Expand Down
16 changes: 16 additions & 0 deletions integration/ng-add/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
16 changes: 16 additions & 0 deletions integration/ng-add/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
45 changes: 45 additions & 0 deletions integration/ng-add/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events*.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
61 changes: 61 additions & 0 deletions integration/ng-add/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("//tools:integration.bzl", "CLI_PROJECT_MAPPINGS")
load("//tools:defaults.bzl", "node_integration_test")

npmPackageMappings = dicts.add(
CLI_PROJECT_MAPPINGS,
{
"//src/cdk:npm_package_archive": "@angular/cdk",
"//src/material:npm_package_archive": "@angular/material",
},
)

node_integration_test(
name = "test",
srcs = glob(["**/*"]),
commands = [
# Note: We use a cache folder within the integration test as otherwise
# the NPM package mapped archive would be cached in the system.
# See: https://github.com/yarnpkg/yarn/issues/2165.
# TODO(devversion): determine if a solution/workaround could live in the test runner.
"yarn install --cache-folder .yarn_cache_folder/",
"yarn ng add @angular/material",
"yarn test",
],
npm_packages = npmPackageMappings,
tags = [
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
# Additionally, we need to disable RBE as this test relies on internet
# access for installing the NPM packages.
"no-sandbox",
"no-remote-exec",
],
)

node_integration_test(
name = "test_node12",
srcs = glob(["**/*"]),
commands = [
# Note: We use a cache folder within the integration test as otherwise
# the NPM package mapped archive would be cached in the system.
# See: https://github.com/yarnpkg/yarn/issues/2165.
# TODO(devversion): determine if a solution/workaround could live in the test runner.
"yarn install --cache-folder .yarn_cache_folder/",
"node --version",
"yarn node --version",
"yarn ng add @angular/material",
"yarn test",
],
npm_packages = npmPackageMappings,
tags = [
# Chromium cannot run in Sandbox. For this test, sandbox is disabled.
# Additionally, we need to disable RBE as this test relies on internet
# access for installing the NPM packages.
"no-sandbox",
"no-remote-exec",
],
tool_mappings = {
"@node12_host//:yarn_bin": "yarn",
"@node12_host//:node_bin": "node",
},
)
27 changes: 27 additions & 0 deletions integration/ng-add/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# NgAdd

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.0.0-next.7.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
112 changes: 112 additions & 0 deletions integration/ng-add/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ng-add": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ng-add",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "ng-add:build:production"
},
"development": {
"browserTarget": "ng-add:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ng-add:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [],
"watch": false
}
}
}
}
},
"defaultProject": "ng-add"
}
Loading