From 40d64b6b58a41ac7d8e424277647c94d3815db58 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 22 Jan 2019 18:46:51 +0100 Subject: [PATCH] build: run offline_compiler_test using bazel (#28191) PR Close #28191 --- packages/animations/BUILD.bazel | 1 + packages/common/BUILD.bazel | 1 + packages/compiler-cli/BUILD.bazel | 4 +- packages/compiler-cli/DEVELOPER.md | 28 --- .../compiler-cli/integrationtest/BUILD.bazel | 59 +++++++ .../flat_module/tsconfig-build.json | 21 +-- .../ngtools_src/tsconfig-build.json | 23 +-- .../integrationtest/src/module.ts | 5 - packages/compiler-cli/integrationtest/test.js | 54 ++++++ .../integrationtest/test_helpers.js | 164 ++++++++++++++++++ .../third_party_src/tsconfig-build.json | 20 +-- .../integrationtest/tsconfig-build.json | 38 ++-- .../integrationtest/tsconfig-ngc-build.json | 39 ----- .../integrationtest/tsconfig-xi18n.json | 28 ++- .../integrationtest/webpack.config.js | 19 -- packages/compiler/BUILD.bazel | 1 + packages/core/BUILD.bazel | 1 + packages/forms/BUILD.bazel | 1 + packages/http/BUILD.bazel | 4 +- packages/platform-browser-dynamic/BUILD.bazel | 4 +- packages/platform-browser/BUILD.bazel | 1 + packages/platform-server/BUILD.bazel | 4 +- packages/router/BUILD.bazel | 1 + scripts/ci/offline_compiler_test.sh | 73 -------- 24 files changed, 346 insertions(+), 248 deletions(-) delete mode 100644 packages/compiler-cli/DEVELOPER.md create mode 100644 packages/compiler-cli/integrationtest/BUILD.bazel create mode 100644 packages/compiler-cli/integrationtest/test.js create mode 100644 packages/compiler-cli/integrationtest/test_helpers.js delete mode 100644 packages/compiler-cli/integrationtest/tsconfig-ngc-build.json delete mode 100644 packages/compiler-cli/integrationtest/webpack.config.js delete mode 100755 scripts/ci/offline_compiler_test.sh diff --git a/packages/animations/BUILD.bazel b/packages/animations/BUILD.bazel index 3a7ebe7fa8..b104693eb8 100644 --- a/packages/animations/BUILD.bazel +++ b/packages/animations/BUILD.bazel @@ -29,6 +29,7 @@ ng_package( # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", "//packages/compiler/test:__pkg__", ], deps = [ diff --git a/packages/common/BUILD.bazel b/packages/common/BUILD.bazel index 6a64e0d0f4..a1b53fc202 100644 --- a/packages/common/BUILD.bazel +++ b/packages/common/BUILD.bazel @@ -33,6 +33,7 @@ ng_package( # Dependencies on the full npm_package cause long re-builds. visibility = [ "//packages/bazel/test/ng_package:__pkg__", + "//packages/compiler-cli/integrationtest:__pkg__", "//packages/compiler-cli/test:__pkg__", "//packages/compiler-cli/test/diagnostics:__pkg__", "//packages/compiler-cli/test/ngcc:__pkg__", diff --git a/packages/compiler-cli/BUILD.bazel b/packages/compiler-cli/BUILD.bazel index d7432a145d..4e4688a6f4 100644 --- a/packages/compiler-cli/BUILD.bazel +++ b/packages/compiler-cli/BUILD.bazel @@ -53,7 +53,9 @@ npm_package( ], # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. - visibility = ["//visibility:private"], + visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", + ], deps = [ ":compiler-cli", "//packages/compiler-cli/src/ngcc", diff --git a/packages/compiler-cli/DEVELOPER.md b/packages/compiler-cli/DEVELOPER.md deleted file mode 100644 index 6b37ce29bb..0000000000 --- a/packages/compiler-cli/DEVELOPER.md +++ /dev/null @@ -1,28 +0,0 @@ - -# Legacy docs for @angular/compiler-cli Developers - -*Note from Igor: This doc is likely outdated now but I'm keeping it around because -offline_compiler_test.sh need to be converted to bazel/circleci (or deleted) and these docs seem -relevant to anyone who needs to understand those tests. Once that's done this file can be deleted.* - - -``` -# Build Angular and the compiler -./build.sh - -# Run the test once -# (First edit the LINKABLE_PKGS to use npm link instead of npm install) -$ ./scripts/ci/offline_compiler_test.sh - -# Keep a package fresh in watch mode -./node_modules/.bin/tsc -p packages/compiler/tsconfig-build.json -w - -# Recompile @angular/core module (needs to use tsc-ext to keep the metadata) -$ export NODE_PATH=${NODE_PATH}:$(pwd)/dist/all:$(pwd)/dist/tools -$ node dist/tools/@angular/compiler-cli/src/main -p packages/core/tsconfig-build.json - -# Iterate on the test -$ cd /tmp/wherever/e2e_test.1464388257/ -$ ./node_modules/.bin/ngc -$ ./node_modules/.bin/jasmine test/*_spec.js -``` diff --git a/packages/compiler-cli/integrationtest/BUILD.bazel b/packages/compiler-cli/integrationtest/BUILD.bazel new file mode 100644 index 0000000000..985fdbe756 --- /dev/null +++ b/packages/compiler-cli/integrationtest/BUILD.bazel @@ -0,0 +1,59 @@ +package(default_visibility = ["//visibility:public"]) + +load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_test") +load("//tools:defaults.bzl", "nodejs_binary") + +nodejs_binary( + name = "ngc_bin", + data = [ + "//packages/compiler-cli", + "@ngdeps//chokidar", + "@ngdeps//reflect-metadata", + ], + entry_point = "angular/packages/compiler-cli/src/main.js", +) + +nodejs_binary( + name = "ng_xi18n", + data = [ + "//packages/compiler-cli", + "@ngdeps//chokidar", + "@ngdeps//reflect-metadata", + ], + entry_point = "angular/packages/compiler-cli/src/extract_i18n.js", +) + +nodejs_test( + name = "integrationtest", + data = [ + ":ngc_bin", + ":ng_xi18n", + "@nodejs//:node", + "@ngdeps//domino", + "@ngdeps//chokidar", + "@ngdeps//source-map-support", + "@ngdeps//shelljs", + "@ngdeps//typescript", + "@ngdeps//reflect-metadata", + "@ngdeps//rxjs", + "@ngdeps//tslib", + "@ngdeps//jasmine/bin:jasmine", + "@ngdeps//zone.js", + "@ngdeps//xhr2", + "@ngdeps//@types/node", + "@ngdeps//@types/jasmine", + "//packages/animations:npm_package", + "//packages/common:npm_package", + "//packages/compiler:npm_package", + "//packages/compiler-cli:npm_package", + "//packages/core:npm_package", + "//packages/forms:npm_package", + "//packages/http:npm_package", + "//packages/platform-browser:npm_package", + "//packages/platform-browser-dynamic:npm_package", + "//packages/platform-server:npm_package", + "//packages/router:npm_package", + ] + glob(["**/*"]), + entry_point = "angular/packages/compiler-cli/integrationtest/test.js", + tags = ["no-ivy-aot"], +) diff --git a/packages/compiler-cli/integrationtest/flat_module/tsconfig-build.json b/packages/compiler-cli/integrationtest/flat_module/tsconfig-build.json index 86f8050944..4be4a4fdfa 100644 --- a/packages/compiler-cli/integrationtest/flat_module/tsconfig-build.json +++ b/packages/compiler-cli/integrationtest/flat_module/tsconfig-build.json @@ -1,26 +1,21 @@ { "angularCompilerOptions": { - // For TypeScript 1.8, we have to lay out generated files - // in the same source directory with your code. - "genDir": "ng", "flatModuleId": "flat_module", "flatModuleOutFile": "index.js", "skipTemplateCodegen": true }, "compilerOptions": { - "target": "es5", - "experimentalDecorators": true, - "noImplicitAny": true, - "moduleResolution": "node", - "rootDir": "", - "declaration": true, - "lib": ["es6", "dom"], "baseUrl": ".", + "declaration": true, + "experimentalDecorators": true, + "lib": ["es6", "dom"], + "moduleResolution": "node", + "noImplicitAny": true, "outDir": "../node_modules/flat_module", - // Prevent scanning up the directory tree for types - "typeRoots": ["node_modules/@types"] + "rootDir": "", + "target": "es5" }, "files": ["public-api.ts"] -} \ No newline at end of file +} diff --git a/packages/compiler-cli/integrationtest/ngtools_src/tsconfig-build.json b/packages/compiler-cli/integrationtest/ngtools_src/tsconfig-build.json index 1abc789b13..2a7c12c8bb 100644 --- a/packages/compiler-cli/integrationtest/ngtools_src/tsconfig-build.json +++ b/packages/compiler-cli/integrationtest/ngtools_src/tsconfig-build.json @@ -1,24 +1,17 @@ { "angularCompilerOptions": { - // For TypeScript 1.8, we have to lay out generated files - // in the same source directory with your code. - "genDir": ".", "debug": true }, "compilerOptions": { - "target": "es5", - "experimentalDecorators": true, - "noImplicitAny": true, - "moduleResolution": "node", - "rootDir": "", - "declaration": true, - "lib": [ - "es6", - "dom" - ], "baseUrl": ".", - // don't auto-discover @types/fs-extra + "declaration": true, + "experimentalDecorators": true, + "lib": ["es6", "dom"], + "moduleResolution": "node", + "noImplicitAny": true, + "rootDir": "", + "target": "es5", "types": [] } -} \ No newline at end of file +} diff --git a/packages/compiler-cli/integrationtest/src/module.ts b/packages/compiler-cli/integrationtest/src/module.ts index 3398cb2ddc..a3d8711a93 100644 --- a/packages/compiler-cli/integrationtest/src/module.ts +++ b/packages/compiler-cli/integrationtest/src/module.ts @@ -8,7 +8,6 @@ import {ApplicationRef, NgModule, forwardRef} from '@angular/core'; import {FormsModule} from '@angular/forms'; -import {MATERIAL_SANITY_CHECKS, MdButtonModule} from '@angular/material'; import {ServerModule} from '@angular/platform-server'; import {FlatModule} from 'flat_module'; // Note: don't refer to third_party_src as we want to test that @@ -60,7 +59,6 @@ export {SomeModule as JitSummariesSomeModule} from './jit_summaries'; imports: [ ServerModule, FormsModule, - MdButtonModule, ModuleUsingCustomElements, SomeLibModule.withProviders(), ThirdpartyModule, @@ -69,9 +67,6 @@ export {SomeModule as JitSummariesSomeModule} from './jit_summaries'; providers: [ SomeService, {provide: CUSTOM, useValue: forwardRef(() => ({name: 'some name'}))}, - // disable sanity check for material because it throws an error when used server-side - // see https://github.com/angular/material2/issues/6292 - {provide: MATERIAL_SANITY_CHECKS, useValue: false}, ], entryComponents: [ AnimateCmp, diff --git a/packages/compiler-cli/integrationtest/test.js b/packages/compiler-cli/integrationtest/test.js new file mode 100644 index 0000000000..2b62fd7f0c --- /dev/null +++ b/packages/compiler-cli/integrationtest/test.js @@ -0,0 +1,54 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +const path = require('path'); +const shx = require('shelljs'); +const os = require('os'); +const {runCommand, setupTestDirectory} = require('./test_helpers'); + +const ngcBin = require.resolve('./ngc_bin'); +const xi18nBin = require.resolve('./ng_xi18n'); +const nodeBin = require.resolve(`nodejs/bin/node${(os.platform() === 'win32' ? '.cmd' : '')}`); +const jasmineBin = require.resolve('ngdeps/node_modules/jasmine/bin/jasmine.js'); + +// Prepare the test directory before building the integration test output. This ensures that +// the test runs in an hermetic way and works on Windows. +const tmpDir = setupTestDirectory(); + +// Compile the "flat_module" Angular project using NGC. +runCommand(ngcBin, ['-p', 'flat_module/tsconfig-build.json']); + +// Copy HTML asset files from the "flat_module" package to the NPM output. The "flat_module" +// has template code generation disabled and therefore needs to have the asset files included +// next to the JavaScript output. +shx.cp( + path.join(tmpDir, 'flat_module/src/*.html'), path.join(tmpDir, 'node_modules/flat_module/src')); + +// Compile the "third_party" Angular project using NGC. +runCommand(ngcBin, ['-p', 'third_party_src/tsconfig-build.json']); + +// Compile the main integration-test Angular project using NGC. Also uses a translated +// i18n file which will be used to verify the translated templates of components. +runCommand(ngcBin, [ + '-p', 'tsconfig-build.json', '--i18nFile=src/messages.fi.xlf', '--locale=fi', '--i18nFormat=xlf' +]); + +// Extract the i18n messages into various formats that will be verified +// later on by the "i18n_spec" within "test/". +runCommand(xi18nBin, ['-p', 'tsconfig-xi18n.json', '--i18nFormat=xlf', '--locale=fr']); +runCommand( + xi18nBin, ['-p', 'tsconfig-xi18n.json', '--i18nFormat=xlf2', '--outFile=messages.xliff2.xlf']); +runCommand( + xi18nBin, ['-p', 'tsconfig-xi18n.json', '--i18nFormat=xmb', '--outFile=custom_file.xmb']); + +// Run the ngtools tests that verify that the public API provided by the "compiler-cli" +// is working as expected in real projects. +runCommand(nodeBin, [path.join(tmpDir, 'test/test_ngtools_api.js')]); + +// Run all specs which verify the output from the previously built modules and i18n files. +runCommand(nodeBin, [jasmineBin, path.join(tmpDir, 'test/all_spec.js')]); diff --git a/packages/compiler-cli/integrationtest/test_helpers.js b/packages/compiler-cli/integrationtest/test_helpers.js new file mode 100644 index 0000000000..c638b63c01 --- /dev/null +++ b/packages/compiler-cli/integrationtest/test_helpers.js @@ -0,0 +1,164 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +const child_process = require('child_process'); +const fs = require('fs'); +const path = require('path'); +const shx = require('shelljs'); + +/** Manifest path that refers to the Bazel package that contains all test sources. */ +const baseManifestPath = 'angular/packages/compiler-cli/integrationtest'; + +/** + * Temporary directory which will be used to build and run the integration tests. Note that + * this environment variable is automatically set by Bazel for such test actions. + */ +const tmpDir = process.env.TEST_TMPDIR; + +/** Fine grained node modules which are required in order to run the integration test. */ +const requiredNodeModules = { + '@angular/animations': resolveNpmTreeArtifact('angular/packages/animations/npm_package'), + '@angular/common': resolveNpmTreeArtifact('angular/packages/common/npm_package'), + '@angular/compiler': resolveNpmTreeArtifact('angular/packages/compiler/npm_package'), + '@angular/compiler-cli': resolveNpmTreeArtifact('angular/packages/compiler-cli/npm_package'), + '@angular/core': resolveNpmTreeArtifact('angular/packages/core/npm_package'), + '@angular/forms': resolveNpmTreeArtifact('angular/packages/forms/npm_package'), + '@angular/http': resolveNpmTreeArtifact('angular/packages/http/npm_package'), + '@angular/platform-browser': + resolveNpmTreeArtifact('angular/packages/platform-browser/npm_package'), + '@angular/platform-browser-dynamic': + resolveNpmTreeArtifact('angular/packages/platform-browser-dynamic/npm_package'), + '@angular/platform-server': + resolveNpmTreeArtifact('angular/packages/platform-server/npm_package'), + '@angular/router': resolveNpmTreeArtifact('angular/packages/router/npm_package'), + '@types/jasmine': resolveNpmTreeArtifact('ngdeps/node_modules/@types/jasmine'), + '@types/node': resolveNpmTreeArtifact('ngdeps/node_modules/@types/node'), + + // Transitive dependencies which need to be specified because the Angular NPM packages + // depend on these without the Angular NPM packages being part of the Bazel managed deps. + // This means that transitive dependencies need to be manually declared as required. + 'tslib': resolveNpmTreeArtifact('ngdeps/node_modules/tslib'), + 'domino': resolveNpmTreeArtifact('ngdeps/node_modules/domino'), + 'xhr2': resolveNpmTreeArtifact('ngdeps/node_modules/xhr2'), + + // Fine grained dependencies which are used by the integration test Angular modules, and + // need to be symlinked so that they can be resolved by NodeJS or NGC. + 'reflect-metadata': resolveNpmTreeArtifact('ngdeps/node_modules/reflect-metadata'), + 'rxjs': resolveNpmTreeArtifact('ngdeps/node_modules/rxjs'), + 'source-map-support': resolveNpmTreeArtifact('ngdeps/node_modules/source-map-support'), + 'typescript': resolveNpmTreeArtifact('ngdeps/node_modules/typescript'), + 'zone.js': resolveNpmTreeArtifact('ngdeps/node_modules/zone.js'), +}; + +/** Sets up the temporary test directory and returns the path to the directory. */ +exports.setupTestDirectory = function() { + copySourceFilesToTempDir(); + symlinkNodeModules(); + return tmpDir; +}; + +/** + * Runs a given binary with the specified command line arguments. The working directory for + * the spawned process will be the temporary directory. + */ +exports.runCommand = function runCommand(binary, args = []) { + const ngcProcess = child_process.spawnSync(binary, args, { + stdio: 'inherit', + cwd: tmpDir, + env: { + ...process.env, + // We need to set the "NODE_PATH" here because the built Angular NPM packages are symlinks + // which NodeJS resolves into the output location. This is problematic because the output + // location does not have the required dependencies of these NPM packages installed. This + // could be fixed by setting the NodeJS "--preserve-symlinks" option, but this would mean + // that transitive dependencies of fine-grained dependencies cannot be resolved either. + NODE_PATH: path.join(tmpDir, 'node_modules/') + } + }); + + if (ngcProcess.status !== 0) { + console.error(`Command ${binary} failed with arguments: "${args.join(' ')}". See error above.`); + process.exit(1); + } +}; + +/** + * Symlinks the specified node modules within the temporary directory. This is necessary because + * this test is an integration test and we don't want to rely on any path-mapped module resolution. + * Additionally, NGC expects types and imported packages to be within the project's root dir. + */ +function symlinkNodeModules() { + Object.keys(requiredNodeModules).forEach(importName => { + const outputPath = path.join(tmpDir, 'node_modules', importName); + const moduleDir = requiredNodeModules[importName]; + + findFilesWithinDirectory(moduleDir).forEach(filePath => { + const outputFilePath = path.join(outputPath, path.relative(moduleDir, filePath)); + + shx.mkdir('-p', path.dirname(outputFilePath)); + fs.symlinkSync(filePath, outputFilePath); + }); + }); +} + +/** + * Copies all source files for the integration test to a temporary directory. This + * is necessary because runfiles resolve on Windows to the original source location, + * and we don't want to pollute the workspace sources. This breaks hermeticity. + */ +function copySourceFilesToTempDir() { + getSourceFilesFromRunfiles().forEach(({realPath, relativeFilePath}) => { + const tmpFilePath = path.join(tmpDir, relativeFilePath); + + shx.mkdir('-p', path.dirname(tmpFilePath)); + shx.cp(realPath, tmpFilePath); + }); +} + +/** + * Gets all source files for the integration test by querying the Bazel runfiles. + * In case there is a runfiles manifest (e.g. on Windows), the source files are resolved + * through the manifest because on these platforms the runfiles are not symlinked and + * cannot be searched within the real filesystem. + */ +function getSourceFilesFromRunfiles() { + // Path to the Bazel runfiles manifest if present. This file is present if runfiles are + // not symlinked into the runfiles directory. + const runfilesManifestPath = process.env.RUNFILES_MANIFEST_FILE; + + if (!runfilesManifestPath) { + const packageRunfilesDir = path.join(process.env.RUNFILES, baseManifestPath); + return findFilesWithinDirectory(packageRunfilesDir).map(filePath => ({ + realPath: filePath, + relativeFilePath: path.relative( + packageRunfilesDir, filePath) + })); + } + + return fs.readFileSync(runfilesManifestPath, 'utf8') + .split('\n') + .map(mapping => mapping.split(' ')) + .filter(([runfilePath]) => runfilePath.startsWith(baseManifestPath)) + .map( + ([runfilePath, realPath]) => + ({realPath, relativeFilePath: path.relative(baseManifestPath, runfilePath)})); +} + +/** + * Resolves a NPM package from the Bazel runfiles. We need to resolve the Bazel tree + * artifacts using a "resolve file" because the NodeJS module resolution does not allow + * resolving to directory paths. + */ +function resolveNpmTreeArtifact(manifestPath, resolveFile = 'package.json') { + return path.dirname(require.resolve(path.posix.join(manifestPath, resolveFile))); +} + +/** Finds all files within a specified directory. */ +function findFilesWithinDirectory(directoryPath) { + return shx.find(directoryPath).filter(filePath => !fs.statSync(filePath).isDirectory()); +} diff --git a/packages/compiler-cli/integrationtest/third_party_src/tsconfig-build.json b/packages/compiler-cli/integrationtest/third_party_src/tsconfig-build.json index d9f9f536c3..73801e8354 100644 --- a/packages/compiler-cli/integrationtest/third_party_src/tsconfig-build.json +++ b/packages/compiler-cli/integrationtest/third_party_src/tsconfig-build.json @@ -1,21 +1,17 @@ { "angularCompilerOptions": { - // For TypeScript 1.8, we have to lay out generated files - // in the same source directory with your code. "skipTemplateCodegen": true }, "compilerOptions": { - "target": "es5", - "experimentalDecorators": true, - "noImplicitAny": true, - "moduleResolution": "node", - "rootDir": "", - "declaration": true, - "lib": ["es6", "dom"], "baseUrl": ".", + "declaration": true, + "experimentalDecorators": true, + "lib": ["es6", "dom"], + "moduleResolution": "node", + "noImplicitAny": true, "outDir": "../node_modules/third_party", - // Prevent scanning up the directory tree for types - "typeRoots": ["node_modules/@types"] + "rootDir": "", + "target": "es5" } -} \ No newline at end of file +} diff --git a/packages/compiler-cli/integrationtest/tsconfig-build.json b/packages/compiler-cli/integrationtest/tsconfig-build.json index 511a721e2f..3e9b6559d8 100644 --- a/packages/compiler-cli/integrationtest/tsconfig-build.json +++ b/packages/compiler-cli/integrationtest/tsconfig-build.json @@ -1,40 +1,34 @@ { "angularCompilerOptions": { - // For TypeScript 1.8, we have to lay out generated files - // in the same source directory with your code. - "genDir": ".", + "alwaysCompileGeneratedCode": true, + "annotationsAs": "static fields", "debug": true, "enableSummariesForJit": true, - "alwaysCompileGeneratedCode": true, "i18nFormat": "xlf" }, "compilerOptions": { - "target": "es5", - "experimentalDecorators": true, - "noImplicitAny": true, - "strictNullChecks": true, - "strictPropertyInitialization": true, - "skipLibCheck": true, - "moduleResolution": "node", - "rootDir": "", - "declaration": true, - "lib": ["es6", "dom"], "baseUrl": ".", - // Prevent scanning up the directory tree for types - "typeRoots": ["node_modules/@types"], + "declaration": true, + "experimentalDecorators": true, + "lib": ["es6", "dom"], + "moduleResolution": "node", + "noImplicitAny": true, "noUnusedLocals": true, - "sourceMap": true + "rootDir": "", + "skipLibCheck": true, + "sourceMap": true, + "strictNullChecks": true, + // compatible with the option. Disabled until the integration test support the strict flag. + // TODO(devversion): this has been enabled without the integration test code being + "strictPropertyInitialization": false, + "target": "es5" }, "files": [ "src/module", "src/bootstrap", "test/all_spec", - "test/test_ngtools_api", - "benchmarks/src/tree/ng2/index_aot.ts", - "benchmarks/src/tree/ng2_switch/index_aot.ts", - "benchmarks/src/largetable/ng2/index_aot.ts", - "benchmarks/src/largetable/ng2_switch/index_aot.ts" + "test/test_ngtools_api" ] } diff --git a/packages/compiler-cli/integrationtest/tsconfig-ngc-build.json b/packages/compiler-cli/integrationtest/tsconfig-ngc-build.json deleted file mode 100644 index 5c880dc22d..0000000000 --- a/packages/compiler-cli/integrationtest/tsconfig-ngc-build.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "angularCompilerOptions": { - // For TypeScript 1.8, we have to lay out generated files - // in the same source directory with your code. - "genDir": ".", - "debug": true, - "enableSummariesForJit": true, - "alwaysCompileGeneratedCode": true - }, - - "compilerOptions": { - "target": "es5", - "experimentalDecorators": true, - "noImplicitAny": true, - "strictNullChecks": true, - "strictPropertyInitialization": true, - "skipLibCheck": true, - "moduleResolution": "node", - "rootDir": "", - "declaration": true, - "lib": ["es6", "dom"], - "baseUrl": ".", - // Prevent scanning up the directory tree for types - "typeRoots": ["node_modules/@types"], - "noUnusedLocals": true, - "sourceMap": true - }, - - "files": [ - "src/module", - "src/bootstrap", - "test/all_spec", - "test/test_ngtools_api", - "benchmarks/src/tree/ng2/index_aot.ts", - "benchmarks/src/tree/ng2_switch/index_aot.ts", - "benchmarks/src/largetable/ng2/index_aot.ts", - "benchmarks/src/largetable/ng2_switch/index_aot.ts" - ] -} diff --git a/packages/compiler-cli/integrationtest/tsconfig-xi18n.json b/packages/compiler-cli/integrationtest/tsconfig-xi18n.json index 039931f12c..05a7f38733 100644 --- a/packages/compiler-cli/integrationtest/tsconfig-xi18n.json +++ b/packages/compiler-cli/integrationtest/tsconfig-xi18n.json @@ -1,34 +1,26 @@ { "angularCompilerOptions": { - // For TypeScript 1.8, we have to lay out generated files - // in the same source directory with your code. - "genDir": ".", "debug": true, "enableSummariesForJit": true }, "compilerOptions": { - "target": "es5", - "experimentalDecorators": true, - "noImplicitAny": true, - "moduleResolution": "node", - "outDir": "./out", - "rootDir": "", - "declaration": true, - "lib": ["es6", "dom"], "baseUrl": ".", - // Prevent scanning up the directory tree for types - "typeRoots": ["node_modules/@types"] + "declaration": true, + "experimentalDecorators": true, + "lib": ["es6", "dom"], + "moduleResolution": "node", + "noImplicitAny": true, + "outDir": "./xi18n-out", + "rootDir": "", + "skipLibCheck": true, + "target": "es5" }, "files": [ "src/module", "src/bootstrap", "test/all_spec", - "test/test_ngtools_api", - "benchmarks/src/tree/ng2/index_aot.ts", - "benchmarks/src/tree/ng2_switch/index_aot.ts", - "benchmarks/src/largetable/ng2/index_aot.ts", - "benchmarks/src/largetable/ng2_switch/index_aot.ts" + "test/test_ngtools_api" ] } diff --git a/packages/compiler-cli/integrationtest/webpack.config.js b/packages/compiler-cli/integrationtest/webpack.config.js deleted file mode 100644 index 504f93430c..0000000000 --- a/packages/compiler-cli/integrationtest/webpack.config.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -module.exports = { - target: 'node', - entry: './test/all_spec.js', - output: {filename: './all_spec.js'}, - resolve: {extensions: ['.js']}, - devtool: '#source-map', - module: { - loaders: - [{test: /\.js$/, exclude: /node_modules/, loaders: ['source-map-loader'], enforce: 'pre'}] - }, -}; diff --git a/packages/compiler/BUILD.bazel b/packages/compiler/BUILD.bazel index 5aa5564493..a2d2e78bc4 100644 --- a/packages/compiler/BUILD.bazel +++ b/packages/compiler/BUILD.bazel @@ -26,6 +26,7 @@ ng_package( # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", "//packages/language-service/test:__pkg__", ], deps = [ diff --git a/packages/core/BUILD.bazel b/packages/core/BUILD.bazel index ac15b38b90..78df5ffef1 100644 --- a/packages/core/BUILD.bazel +++ b/packages/core/BUILD.bazel @@ -37,6 +37,7 @@ ng_package( # Dependencies on the full npm_package cause long re-builds. visibility = [ "//packages/bazel/test/ng_package:__pkg__", + "//packages/compiler-cli/integrationtest:__pkg__", "//packages/compiler-cli/test:__pkg__", "//packages/compiler-cli/test/diagnostics:__pkg__", "//packages/compiler-cli/test/ngcc:__pkg__", diff --git a/packages/forms/BUILD.bazel b/packages/forms/BUILD.bazel index 5ee2f385c5..6391e5e16d 100644 --- a/packages/forms/BUILD.bazel +++ b/packages/forms/BUILD.bazel @@ -27,6 +27,7 @@ ng_package( # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", "//packages/compiler-cli/test/diagnostics:__pkg__", "//packages/language-service/test:__pkg__", ], diff --git a/packages/http/BUILD.bazel b/packages/http/BUILD.bazel index 23125871fb..6eabc9e41a 100644 --- a/packages/http/BUILD.bazel +++ b/packages/http/BUILD.bazel @@ -29,7 +29,9 @@ ng_package( ], # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. - visibility = ["//visibility:private"], + visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", + ], deps = [ ":http", "//packages/http/testing", diff --git a/packages/platform-browser-dynamic/BUILD.bazel b/packages/platform-browser-dynamic/BUILD.bazel index a1a42d4622..a0aff4d0ad 100644 --- a/packages/platform-browser-dynamic/BUILD.bazel +++ b/packages/platform-browser-dynamic/BUILD.bazel @@ -31,7 +31,9 @@ ng_package( ], # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. - visibility = ["//visibility:private"], + visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", + ], deps = [ ":platform-browser-dynamic", "//packages/platform-browser-dynamic/testing", diff --git a/packages/platform-browser/BUILD.bazel b/packages/platform-browser/BUILD.bazel index a9a9c74aa9..4205044eed 100644 --- a/packages/platform-browser/BUILD.bazel +++ b/packages/platform-browser/BUILD.bazel @@ -33,6 +33,7 @@ ng_package( # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", "//packages/compiler-cli/test:__pkg__", ], deps = [ diff --git a/packages/platform-server/BUILD.bazel b/packages/platform-server/BUILD.bazel index c7a74c43ca..7e4e0022a8 100644 --- a/packages/platform-server/BUILD.bazel +++ b/packages/platform-server/BUILD.bazel @@ -38,7 +38,9 @@ ng_package( ], # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. - visibility = ["//visibility:private"], + visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", + ], deps = [ ":platform-server", "//packages/platform-server/testing", diff --git a/packages/router/BUILD.bazel b/packages/router/BUILD.bazel index d789660055..480deb3a88 100644 --- a/packages/router/BUILD.bazel +++ b/packages/router/BUILD.bazel @@ -33,6 +33,7 @@ ng_package( # Do not add more to this list. # Dependencies on the full npm_package cause long re-builds. visibility = [ + "//packages/compiler-cli/integrationtest:__pkg__", "//packages/compiler-cli/test:__pkg__", "//packages/compiler-cli/test/transformers:__pkg__", ], diff --git a/scripts/ci/offline_compiler_test.sh b/scripts/ci/offline_compiler_test.sh deleted file mode 100755 index f44acfadbb..0000000000 --- a/scripts/ci/offline_compiler_test.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash - -set -u -e -o pipefail - -# npm 5 symlinks from local file installations rather than copying files, but -# webpack will not follow the symlinks. -# We prefer to emulate how a user will install angular, so we `npm pack` the -# packages, then install them from the resulting .tgz files later. -ANGULAR_PKGS=$(npm pack dist/packages-dist/{common,forms,core,compiler,compiler-cli,platform-{browser,server},platform-browser-dynamic,router,http,animations} | awk "{ printf \"$PWD/\"; print }") - - -PKGS=( - $PWD/node_modules/typescript - $PWD/node_modules/reflect-metadata - $PWD/node_modules/rxjs - $PWD/node_modules/zone.js - @types/{node@6.0.38,jasmine@2.2.33} - jasmine@2.4.1 - webpack@2.1.0-beta.21 - source-map-loader@0.2.0 - @angular/{material,cdk}@2.0.0-beta.10 -) - -TMPDIR=${TMPDIR:-.} -readonly TMP=$TMPDIR/e2e_test.$(date +%s) -mkdir -p $TMP -cp -R -v packages/compiler-cli/integrationtest/* $TMP -cp -R -v modules/benchmarks $TMP -# Try to use the same versions as angular, in particular, this will -# cause us to install the same rxjs version. -cp -v package.json $TMP - -# run in subshell to avoid polluting cwd -( - cd $TMP - set -ex -o pipefail - npm install ${PKGS[*]} - npm install ${ANGULAR_PKGS[*]} - - ./node_modules/.bin/tsc --version - # Compile the compiler-cli third_party simulation. - # Use ngc-wrapped directly so we don't produce *.ngfactory.ts files! - - # Compile the compiler-cli integration tests - # TODO(vicb): restore the test for .xtb - #./node_modules/.bin/ngc -p tsconfig-build.json --i18nFile=src/messages.fi.xtb --locale=fi --i18nFormat=xtb - - # Generate the metadata for the third-party modules - ./node_modules/.bin/ngc -p third_party_src/tsconfig-build.json - - # Generate the the bundle modules - ./node_modules/.bin/ngc -p flat_module/tsconfig-build.json - - # Copy the html files from source to the emitted output - cp flat_module/src/*.html node_modules/flat_module/src - - ./node_modules/.bin/ngc -p tsconfig-build.json --i18nFile=src/messages.fi.xlf --locale=fi --i18nFormat=xlf - - ./node_modules/.bin/ng-xi18n -p tsconfig-xi18n.json --i18nFormat=xlf --locale=fr - ./node_modules/.bin/ng-xi18n -p tsconfig-xi18n.json --i18nFormat=xlf2 --outFile=messages.xliff2.xlf - ./node_modules/.bin/ng-xi18n -p tsconfig-xi18n.json --i18nFormat=xmb --outFile=custom_file.xmb - - node test/test_ngtools_api.js - - ./node_modules/.bin/jasmine init - # Run compiler-cli integration tests in node - ./node_modules/.bin/webpack ./webpack.config.js - ./node_modules/.bin/jasmine ./all_spec.js - - # Compile again with a differently named tsconfig file - mv tsconfig-build.json othername.json - ./node_modules/.bin/ngc -p othername.json -)