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

Conversation

devversion
Copy link
Member

Fixes that ng-add does not work because we ship ES2020 currently for schematic code. This commit changes
the target to ES2015 for schematics and also wires up integration tests for ng-add and ng-update. This is in preparation
of us having better testing for changes like APF v13.

Updates the shared dev-infra package to the latest version which comes
with a Bazel rule for running integration tests.

We also install the CLI which we are going to test within some
integration tests that are added at a later time.
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 13, 2021
@devversion devversion added this to the 13.0.0 milestone Oct 13, 2021
@devversion devversion added the P2 The issue is important to a large percentage of users, with a workaround label Oct 13, 2021
Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I think there is improvements we can make long term as we improve/expand the integration_test rule and support for multiple node versions

@devversion devversion force-pushed the feat/integration-ng-update-fix branch from 44d6dbd to 8bf0e03 Compare October 13, 2021 18:35
@devversion devversion added action: merge The PR is ready for merge by the caretaker target: rc This PR is targeted for the next release-candidate labels Oct 13, 2021
Updates the build tooling to prepare NPM packages from the project
`package.json` to be accessible to the Bazel-based integration tests.

The idea is to build tarballs for all NPM packages which can be mapped
into Bazel-based integration tests. This allows us to only have a single
dependency on e.g. the CLI, instead of having to maintain/update
multiple versions of the CLI and devkit (as an example).

Additionally, we will expose tarballs for the first-party built NPM
packages like the CDK or Angular Material.

Lastly, we will populate the `0.0.0-PLACEHOLDER` with an actual version
when stamping is disabled. This allows us to use the first-party built
NPM packages in tests with `yarn`. Yarn would otherwise complain about
an invalid version.
Sets up another toolchain for the NodeJS v12 version. This allows us
to use Node v12 in integration tests without having to manually manage
the Node version in the integration test which runs usually with the
default Node workspace toolchain.

Note that we need a small patch to `rules_nodejs` as the standalone
node toolchain feature is technically internal (but shipped). Rules
NodeJS is in progress of migrating from their current workspace name
to `@rules_nodejs//`. We temporarily patch the external repository to
work with the workspace name we use with `@build_bazel_rules_nodejs#v4`.
Sets up a new CLI project for testing that `ng update` works properly
with APF v13. The CLI project is generated through `ng new`. Also
the `ng add @angular/material` command has been executed and changes
are incorporated into this commit.
Sets up the `ng update` v13 integration test to run with Bazel. The
test will run `ng update` for the CDK and Material and will then compare
the migrated files against some expectation files. like for custom theme
file where the tilde should be removed.
This commit switches the schematic code to build as ES2015. This is
necessary to support Node v12 which is still supported in LTS mode
Creates a CLI project for the `ng-add` integration test that
we will configure to run in a followed commit.
Sets up the integration test for running `ng add` to run
with Bazel. The test is also run with NodeJS v12 which does
not support ES2020 output.
The CLI-generated projects for integration tests are not necessarily
compliant with the lint rules and they should remain as unmodified as possible.
@devversion devversion force-pushed the feat/integration-ng-update-fix branch from 8bf0e03 to 2500c3c Compare October 13, 2021 18:37
Reenables normal integration tests. There weren't any before, so we had to comment out the CircleCI run command.
We updated the linker integration test to ESM, so that it works
with the Angular compiler-cli ESM package. For this, the integration
test utils are now ESM as well. This means that the ts-compat test
relying on these ESM files needs to use ESM as well.

The error didn't surface because with APF v13 switch we acidentally
stopped running the test.
@devversion devversion force-pushed the feat/integration-ng-update-fix branch from 2500c3c to e284caa Compare October 13, 2021 18:43
@devversion devversion marked this pull request as ready for review October 13, 2021 18:49
@devversion devversion requested review from jelbourn and a team as code owners October 13, 2021 18:49
@devversion devversion removed request for a team and jelbourn October 13, 2021 18:49
@zarend zarend merged commit f698259 into angular:master Oct 13, 2021
zarend pushed a commit that referenced this pull request Oct 13, 2021
…deJS 12.x (#23744)

* build: update shared dev-infra package version and install CLI packages

Updates the shared dev-infra package to the latest version which comes
with a Bazel rule for running integration tests.

We also install the CLI which we are going to test within some
integration tests that are added at a later time.

* build: prepare NPM packages for use in Bazel-based integration tests

Updates the build tooling to prepare NPM packages from the project
`package.json` to be accessible to the Bazel-based integration tests.

The idea is to build tarballs for all NPM packages which can be mapped
into Bazel-based integration tests. This allows us to only have a single
dependency on e.g. the CLI, instead of having to maintain/update
multiple versions of the CLI and devkit (as an example).

Additionally, we will expose tarballs for the first-party built NPM
packages like the CDK or Angular Material.

Lastly, we will populate the `0.0.0-PLACEHOLDER` with an actual version
when stamping is disabled. This allows us to use the first-party built
NPM packages in tests with `yarn`. Yarn would otherwise complain about
an invalid version.

* build: setup toolchain for nodejs v12 for integration tests

Sets up another toolchain for the NodeJS v12 version. This allows us
to use Node v12 in integration tests without having to manually manage
the Node version in the integration test which runs usually with the
default Node workspace toolchain.

Note that we need a small patch to `rules_nodejs` as the standalone
node toolchain feature is technically internal (but shipped). Rules
NodeJS is in progress of migrating from their current workspace name
to `@rules_nodejs//`. We temporarily patch the external repository to
work with the workspace name we use with `@build_bazel_rules_nodejs#v4`.

* build: create CLI project for `ng update` v13 integration test

Sets up a new CLI project for testing that `ng update` works properly
with APF v13. The CLI project is generated through `ng new`. Also
the `ng add @angular/material` command has been executed and changes
are incorporated into this commit.

* test: setup ng-update v13 integration test with Bazel

Sets up the `ng update` v13 integration test to run with Bazel. The
test will run `ng update` for the CDK and Material and will then compare
the migrated files against some expectation files. like for custom theme
file where the tilde should be removed.

* build: ship schematic code with ES2015 as target

This commit switches the schematic code to build as ES2015. This is
necessary to support Node v12 which is still supported in LTS mode

* build: create CLI project for `ng-add` integration test

Creates a CLI project for the `ng-add` integration test that
we will configure to run in a followed commit.

* test: setup integration test for running `ng add`

Sets up the integration test for running `ng add` to run
with Bazel. The test is also run with NodeJS v12 which does
not support ES2020 output.

* ci: disable linting of the CLI integration test projects

The CLI-generated projects for integration tests are not necessarily
compliant with the lint rules and they should remain as unmodified as possible.

* ci: re-enable normal integration tests on CI

Reenables normal integration tests. There weren't any before, so we had to comment out the CircleCI run command.

* build: update ts-compat integration test to work with ESM

We updated the linker integration test to ESM, so that it works
with the Angular compiler-cli ESM package. For this, the integration
test utils are now ESM as well. This means that the ts-compat test
relying on these ESM files needs to use ESM as well.

The error didn't surface because with APF v13 switch we acidentally
stopped running the test.

(cherry picked from commit f698259)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants