fix(bazel): Remove angular devkit and restore ngc postinstall (#32946)

This commit removes `@angular-devkit/build-angular` from package.json
for a project that opts into Bazel. This is because the package adds a
dependency on node-sass, which is rejected by Bazel due to its absense.

This commit also appends to `scripts.postinstall` if it already exists.
This is needed because `ng new` in CLI v9 now automatically adds a
postinstall step for `ngcc`.

PR Close #32946
This commit is contained in:
Keen Yee Liau
2019-10-16 16:28:09 -07:00
committed by Matias Niemelä
parent 86e1e6c082
commit f0366843ea
3 changed files with 82 additions and 5 deletions

View File

@ -21,7 +21,7 @@ function installLocalPackages() {
local_packages+=("tslib@file:${pwd}/../../../node_modules/tslib")
local_packages+=("@types/node@file:${pwd}/../../../node_modules/@types/node")
yarn add "${local_packages[@]}"
yarn add --ignore-scripts --silent "${local_packages[@]}"
}
@ -50,13 +50,19 @@ function testNonBazel() {
# Replace angular.json that uses Bazel builder with the default generated by CLI
mv ./angular.json.bak ./angular.json
rm -rf dist src/main.dev.ts src/main.prod.ts
yarn webdriver-manager update --gecko=false --standalone=false ${CI_CHROMEDRIVER_VERSION_ARG:---versions.chrome 2.45}
# disable CLI's version check (if version is 0.0.0, then no version check happens)
yarn --cwd node_modules/@angular/cli version --new-version 0.0.0 --no-git-tag-version
# re-add build-angular
yarn add --dev @angular-devkit/build-angular@0.900.0-next.11
yarn webdriver-manager update --gecko=false --standalone=false ${CI_CHROMEDRIVER_VERSION_ARG:---versions.chrome 2.45}
ng build --progress=false
ng test --progress=false --watch=false
ng e2e --configuration=production --webdriver-update=false
}
testBazel
# this test verifies that users can undo bazel - the value of this is questionable
# because there are way too many manual steps and it would be easier for users to
# just revert the diff created by `ng add @angular/bazel`
testNonBazel