diff --git a/.circleci/config.yml b/.circleci/config.yml index b1d4f9b387..3a4eb40426 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -201,6 +201,19 @@ jobs: # Run e2e tests - run: yarn --cwd aio e2e + test_aio_local_ivy: + <<: *job_defaults + steps: + - checkout: + <<: *post_checkout + - restore_cache: + key: *cache_key + - attach_workspace: + at: dist + - *define_env_vars + # Build aio with Ivy (using local Angular packages) + - run: yarn --cwd aio build-with-ivy --progress=false + test_aio_tools: <<: *job_defaults steps: @@ -497,6 +510,9 @@ workflows: - test_aio_local: requires: - build-packages-dist + - test_aio_local_ivy: + requires: + - build-packages-dist - test_aio_tools: requires: - build-packages-dist @@ -526,6 +542,7 @@ workflows: - integration_test # Only publish if `aio`/`docs` tests using the locally built Angular packages pass - test_aio_local + - test_aio_local_ivy - test_docs_examples # Get the artifacts to publish from the build-packages-dist job # since the publishing script expects the legacy outputs layout. diff --git a/aio/package.json b/aio/package.json index 5a12d6dac4..23ad5e31a5 100644 --- a/aio/package.json +++ b/aio/package.json @@ -17,6 +17,8 @@ "build": "yarn ~~build", "prebuild-local": "yarn setup-local", "build-local": "yarn ~~build", + "prebuild-with-ivy": "yarn setup-local && yarn ivy-ngcc", + "build-with-ivy": "node scripts/build-with-ivy", "extract-cli-command-docs": "node tools/transforms/cli-docs-package/extract-cli-commands.js fd4e960d6", "lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint && yarn tools-lint", "test": "yarn check-env && ng test", diff --git a/aio/scripts/build-with-ivy.js b/aio/scripts/build-with-ivy.js new file mode 100644 index 0000000000..8c159970f5 --- /dev/null +++ b/aio/scripts/build-with-ivy.js @@ -0,0 +1,46 @@ +#!/usr/bin/env node + +// Imports +const {extend, parse} = require('cjson'); +const {readFileSync, writeFileSync} = require('fs'); +const {join, resolve} = require('path'); +const {exec, set} = require('shelljs'); + +set('-e'); + +// Constants +const ROOT_DIR = resolve(__dirname, '..'); +const TS_CONFIG_PATH = join(ROOT_DIR, 'tsconfig.json'); +const NG_COMPILER_OPTS = { + angularCompilerOptions: { + // Related Jira issue: FW-737 + allowEmptyCodegenFiles: true, + enableIvy: 'ngtsc', + }, +}; + +// Run +_main(process.argv.slice(2)); + +// Functions - Definitions +function _main(buildArgs) { + console.log('\nModifying `tsconfig.json`...'); + const oldTsConfigStr = readFileSync(TS_CONFIG_PATH, 'utf8'); + const oldTsConfigObj = parse(oldTsConfigStr); + const newTsConfigObj = extend(true, oldTsConfigObj, NG_COMPILER_OPTS); + const newTsConfigStr = JSON.stringify(newTsConfigObj, null, 2); + writeFileSync(TS_CONFIG_PATH, newTsConfigStr); + console.log(newTsConfigStr); + + try { + const buildArgsStr = buildArgs.join(' '); + + console.log(`\nBuilding${buildArgsStr && ` with args \`${buildArgsStr}\``}...`); + exec(`yarn ~~build ${buildArgsStr}`, {cwd: ROOT_DIR}); + } finally { + console.log('\nRestoring `tsconfig.json`...'); + writeFileSync(TS_CONFIG_PATH, oldTsConfigStr); + } + + console.log('\nDone!'); +}