build(bazel): use bazel managed node_modules for downstream angular from source build support (#24663)

PR Close #24663
This commit is contained in:
Greg Magolan 2018-06-25 11:22:23 -07:00 committed by Igor Minar
parent 323faf954b
commit 1d051c5841
25 changed files with 1231 additions and 1125 deletions

View File

@ -15,220 +15,19 @@ alias(
actual = "@nodejs//:yarn", actual = "@nodejs//:yarn",
) )
node_modules_filegroup( alias(
name = "node_modules", name = "node_modules",
packages = [ actual = "@angular_deps//:node_modules",
"adm-zip",
"ajv",
"angular",
"angular-1.5",
"angular-mocks",
"angular-mocks-1.5",
"anymatch",
"arr-diff",
"arr-flatten",
"arr-union",
"array-unique",
"asn1",
"assert-plus",
"assign-symbols",
"async-each",
"asynckit",
"atob",
"aws-sign2",
"aws4",
"balanced-match",
"base",
"base64-js",
"binary-extensions",
"blocking-proxy",
"brace-expansion",
"braces",
"bytebuffer",
"cache-base",
"caseless",
"chokidar",
"class-utils",
"co",
"collection-visit",
"combined-stream",
"component-emitter",
"concat-map",
"copy-descriptor",
"core-util-is",
"debug",
"decode-uri-component",
"define-property",
"delayed-stream",
"domino",
"expand-brackets",
"expand-range",
"extend",
"extend-shallow",
"extglob",
"extsprintf",
"fast-deep-equal",
"fast-json-stable-stringify",
"filename-regex",
"fill-range",
"for-in",
"for-own",
"forever-agent",
"form-data",
"fragment-cache",
"fs.realpath",
"get-value",
"glob",
"glob-base",
"glob-parent",
"graceful-fs",
"hammerjs",
"har-schema",
"har-validator",
"has-value",
"has-values",
"http-signature",
"https-proxy-agent",
"inflight",
"inherits",
"is-accessor-descriptor",
"is-binary-path",
"is-buffer",
"is-data-descriptor",
"is-descriptor",
"is-dotfile",
"is-equal-shallow",
"is-extendable",
"is-extglob",
"is-glob",
"is-number",
"is-plain-object",
"is-posix-bracket",
"is-primitive",
"is-typedarray",
"is-windows",
"isarray",
"isobject",
"isstream",
"jasmine",
"jasmine-core",
"jasminewd2",
"json-schema",
"json-schema-traverse",
"json-stable-stringify",
"json-stringify-safe",
"jsprim",
"kind-of",
"long",
"lru-cache",
"map-cache",
"map-visit",
"math-random",
"micromatch",
"mime-db",
"mime-types",
"minimatch",
"minimist",
"mixin-deep",
"nanomatch",
"normalize-path",
"oauth-sign",
"object.omit",
"object.pick",
"object-copy",
"object-visit",
"once",
"optimist",
"options",
"os-tmpdir",
"parse-glob",
"pascalcase",
"path-dirname",
"path-is-absolute",
"performance-now",
"posix-character-classes",
"preserve",
"process-nextick-args",
"protobufjs",
"protractor",
"qs",
"randomatic",
"readable-stream",
"readdirp",
"reflect-metadata",
"regex-cache",
"regex-not",
"remove-trailing-separator",
"repeat-element",
"repeat-string",
"request",
"ret",
"rimraf",
"safe-buffer",
"safe-regex",
"sax",
"semver",
"set-immediate-shim",
"set-value",
"shelljs",
"sigmund",
"snapdragon",
"snapdragon-node",
"snapdragon-util",
"source-map",
"source-map-resolve",
"source-map-support",
"source-map-url",
"split-string",
"sshpk",
"static-extend",
"stringstream",
"tmp",
"to-object-path",
"to-regex",
"to-regex-range",
"tough-cookie",
"tsickle",
"tslib",
"tsutils",
"tunnel-agent",
"typescript",
"union-value",
"unset-value",
"upath",
"uri-js",
"urix",
"use",
"util-deprecate",
"uuid",
"verror",
"webdriver-js-extender",
"webdriver-manager",
"wordwrap",
"wrappy",
"xhr2",
"xml2js",
"xmlbuilder",
"zone.js",
"@angular-devkit/core",
"@angular-devkit/schematics",
"@types",
"@webcomponents/custom-elements",
],
patterns = [
"node_modules/protractor/**",
"node_modules/@schematics/angular/**",
],
) )
filegroup( filegroup(
name = "web_test_bootstrap_scripts", name = "web_test_bootstrap_scripts",
# do not sort # do not sort
srcs = [ srcs = [
"//:node_modules/reflect-metadata/Reflect.js", "@angular_deps//:node_modules/reflect-metadata/Reflect.js",
"//:node_modules/zone.js/dist/zone.js", "@angular_deps//:node_modules/zone.js/dist/zone.js",
"//:node_modules/zone.js/dist/zone-testing.js", "@angular_deps//:node_modules/zone.js/dist/zone-testing.js",
"//:node_modules/zone.js/dist/task-tracking.js", "@angular_deps//:node_modules/zone.js/dist/task-tracking.js",
"//:test-events.js", "//:test-events.js",
], ],
) )
@ -236,9 +35,9 @@ filegroup(
filegroup( filegroup(
name = "angularjs_scripts", name = "angularjs_scripts",
srcs = [ srcs = [
"//:node_modules/angular-1.5/angular.js", "@angular_deps//:node_modules/angular-1.5/angular.js",
"//:node_modules/angular-mocks-1.5/angular-mocks.js", "@angular_deps//:node_modules/angular-mocks-1.5/angular-mocks.js",
"//:node_modules/angular-mocks/angular-mocks.js", "@angular_deps//:node_modules/angular-mocks/angular-mocks.js",
"//:node_modules/angular/angular.js", "@angular_deps//:node_modules/angular/angular.js",
], ],
) )

View File

@ -6,9 +6,9 @@ workspace(name = "angular")
http_archive( http_archive(
name = "build_bazel_rules_nodejs", name = "build_bazel_rules_nodejs",
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.10.1.zip", url = "https://github.com/bazelbuild/rules_nodejs/archive/20ff5892612f8359aec8aaf26dd3902a24976ada.zip",
strip_prefix = "rules_nodejs-0.10.1", strip_prefix = "rules_nodejs-20ff5892612f8359aec8aaf26dd3902a24976ada",
sha256 = "634206524d90dc03c52392fa3f19a16637d2bcf154910436fe1d669a0d9d7b9c", sha256 = "07da9d4c3e688a02745d0f50709a87744706d4f5d1959b799b0ac38e97acd622",
) )
http_archive( http_archive(
@ -71,6 +71,22 @@ http_archive(
sha256 = "8a517806d2b7c8505ba5c53934e7d7c70d341b68ffd268e9044d35b564a48828", sha256 = "8a517806d2b7c8505ba5c53934e7d7c70d341b68ffd268e9044d35b564a48828",
) )
#
# Point Bazel to WORKSPACEs that live in subdirectories
#
local_repository(
name = "rxjs",
path = "node_modules/rxjs/src",
)
# Point to the integration test workspace just so that Bazel doesn't descend into it
# when expanding the //... pattern
local_repository(
name = "bazel_integration_test",
path = "integration/bazel",
)
# #
# Load and install our dependencies downloaded above. # Load and install our dependencies downloaded above.
# #
@ -100,26 +116,10 @@ load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
ts_setup_workspace() ts_setup_workspace()
load("//packages/bazel/src:ng_setup_workspace.bzl", "ng_setup_workspace") load("@angular//:index.bzl", "ng_setup_workspace")
ng_setup_workspace() ng_setup_workspace()
#
# Point Bazel to WORKSPACEs that live in subdirectories
#
local_repository(
name = "rxjs",
path = "node_modules/rxjs/src",
)
# Point to the integration test workspace just so that Bazel doesn't descend into it
# when expanding the //... pattern
local_repository(
name = "bazel_integration_test",
path = "integration/bazel",
)
# #
# Ask Bazel to manage these toolchain dependencies for us. # Ask Bazel to manage these toolchain dependencies for us.
# Bazel will run `yarn install` when one of these toolchains is requested during # Bazel will run `yarn install` when one of these toolchains is requested during

19
index.bzl Normal file
View File

@ -0,0 +1,19 @@
# 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
""" Public API surface is re-exported here.
"""
load("//packages/bazel:index.bzl",
_ng_module = "ng_module",
_ng_package = "ng_package",
_protractor_web_test = "protractor_web_test",
_protractor_web_test_suite = "protractor_web_test_suite")
load("//tools:ng_setup_workspace.bzl", _ng_setup_workspace = "ng_setup_workspace")
ng_module = _ng_module
ng_package = _ng_package
protractor_web_test = _protractor_web_test
protractor_web_test_suite = _protractor_web_test_suite
ng_setup_workspace = _ng_setup_workspace

View File

@ -38,6 +38,20 @@ http_archive(
sha256 = "b243c4d64f054c174051785862ab079050d90b37a1cef7da93821c6981cb9ad4", sha256 = "b243c4d64f054c174051785862ab079050d90b37a1cef7da93821c6981cb9ad4",
) )
#
# Point Bazel to WORKSPACEs that live in subdirectories
#
local_repository(
name = "angular",
path = "node_modules/@angular/bazel",
)
local_repository(
name = "rxjs",
path = "node_modules/rxjs/src",
)
# #
# Load and install our dependencies downloaded above. # Load and install our dependencies downloaded above.
# #
@ -68,24 +82,6 @@ load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
sass_repositories() sass_repositories()
#
# Point Bazel to WORKSPACEs that live in subdirectories
#
local_repository(
name = "angular",
path = "node_modules/@angular/bazel",
)
local_repository(
name = "rxjs",
path = "node_modules/rxjs/src",
)
#
# Load and install our dependencies from local repositories
#
load("@angular//:index.bzl", "ng_setup_workspace") load("@angular//:index.bzl", "ng_setup_workspace")
ng_setup_workspace() ng_setup_workspace()

View File

@ -110,6 +110,7 @@ module.exports = function(config) {
// don't need this entire config file. // don't need this entire config file.
proxies: { proxies: {
'/base/angular/': '/base/', '/base/angular/': '/base/',
'/base/angular_deps/': '/base/',
}, },
reporters: ['dots'], reporters: ['dots'],

View File

@ -29,7 +29,7 @@ describe('largeform benchmark perf', () => {
[CreateAndDestroyWorker].forEach((worker) => { [CreateAndDestroyWorker].forEach((worker) => {
describe(worker.id, () => { describe(worker.id, () => {
it('should run for ng2', (done) => { it('should run for ng2', (done: any) => {
runLargeFormBenchmark({ runLargeFormBenchmark({
id: `largeform.ng2.${worker.id}`, id: `largeform.ng2.${worker.id}`,
url: 'all/benchmarks/src/largeform/ng2/index.html', url: 'all/benchmarks/src/largeform/ng2/index.html',

View File

@ -40,7 +40,7 @@ describe('largetable benchmark perf', () => {
[CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => { [CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => {
describe(worker.id, () => { describe(worker.id, () => {
it('should run for ng2', (done) => { it('should run for ng2', (done: any) => {
runTableBenchmark({ runTableBenchmark({
id: `largeTable.ng2.${worker.id}`, id: `largeTable.ng2.${worker.id}`,
url: 'all/benchmarks/src/largetable/ng2/index.html', url: 'all/benchmarks/src/largetable/ng2/index.html',
@ -48,7 +48,7 @@ describe('largetable benchmark perf', () => {
}).then(done, done.fail); }).then(done, done.fail);
}); });
it('should run for ng2 with ngSwitch', (done) => { it('should run for ng2 with ngSwitch', (done: any) => {
runTableBenchmark({ runTableBenchmark({
id: `largeTable.ng2_switch.${worker.id}`, id: `largeTable.ng2_switch.${worker.id}`,
url: 'all/benchmarks/src/largetable/ng2_switch/index.html', url: 'all/benchmarks/src/largetable/ng2_switch/index.html',
@ -56,7 +56,7 @@ describe('largetable benchmark perf', () => {
}).then(done, done.fail); }).then(done, done.fail);
}); });
it('should run for render3', (done) => { it('should run for render3', (done: any) => {
runTableBenchmark({ runTableBenchmark({
id: `largeTable.render3.${worker.id}`, id: `largeTable.render3.${worker.id}`,
url: 'all/benchmarks/src/largetable/render3/index.html', url: 'all/benchmarks/src/largetable/render3/index.html',
@ -65,7 +65,7 @@ describe('largetable benchmark perf', () => {
}).then(done, done.fail); }).then(done, done.fail);
}); });
it('should run for iv', (done) => { it('should run for iv', (done: any) => {
runTableBenchmark({ runTableBenchmark({
id: `largeTable.iv.${worker.id}`, id: `largeTable.iv.${worker.id}`,
url: 'all/benchmarks/src/largetable/iv/index.html', url: 'all/benchmarks/src/largetable/iv/index.html',
@ -74,7 +74,7 @@ describe('largetable benchmark perf', () => {
}).then(done, done.fail); }).then(done, done.fail);
}); });
it('should run for the baseline', (done) => { it('should run for the baseline', (done: any) => {
runTableBenchmark({ runTableBenchmark({
id: `largeTable.baseline.${worker.id}`, id: `largeTable.baseline.${worker.id}`,
url: 'all/benchmarks/src/largetable/baseline/index.html', url: 'all/benchmarks/src/largetable/baseline/index.html',
@ -83,7 +83,7 @@ describe('largetable benchmark perf', () => {
}).then(done, done.fail); }).then(done, done.fail);
}); });
it('should run for incremental-dom', (done) => { it('should run for incremental-dom', (done: any) => {
runTableBenchmark({ runTableBenchmark({
id: `largeTable.incremental_dom.${worker.id}`, id: `largeTable.incremental_dom.${worker.id}`,
url: 'all/benchmarks/src/largetable/incremental_dom/index.html', url: 'all/benchmarks/src/largetable/incremental_dom/index.html',

View File

@ -24,7 +24,7 @@ describe('tree benchmark perf', () => {
Benchmarks.forEach(benchmark => { Benchmarks.forEach(benchmark => {
describe(benchmark.id, () => { describe(benchmark.id, () => {
// This is actually a destroyOnly benchmark // This is actually a destroyOnly benchmark
it('should work for createOnly', (done) => { it('should work for createOnly', (done: any) => {
runTreeBenchmark({ runTreeBenchmark({
id: 'createOnly', id: 'createOnly',
benchmark, benchmark,
@ -33,7 +33,7 @@ describe('tree benchmark perf', () => {
}).then(done, done.fail); }).then(done, done.fail);
}); });
it('should work for createOnlyForReal', (done) => { it('should work for createOnlyForReal', (done: any) => {
runTreeBenchmark({ runTreeBenchmark({
id: 'createOnlyForReal', id: 'createOnlyForReal',
benchmark, benchmark,
@ -42,7 +42,7 @@ describe('tree benchmark perf', () => {
}).then(done, done.fail); }).then(done, done.fail);
}); });
it('should work for createDestroy', (done) => { it('should work for createDestroy', (done: any) => {
runTreeBenchmark({ runTreeBenchmark({
id: 'createDestroy', id: 'createDestroy',
benchmark, benchmark,
@ -53,13 +53,13 @@ describe('tree benchmark perf', () => {
}).then(done, done.fail); }).then(done, done.fail);
}); });
it('should work for update', (done) => { it('should work for update', (done: any) => {
runTreeBenchmark({id: 'update', benchmark, work: () => $(CreateBtn).click()}) runTreeBenchmark({id: 'update', benchmark, work: () => $(CreateBtn).click()})
.then(done, done.fail); .then(done, done.fail);
}); });
if (benchmark.buttons.indexOf(DetectChangesBtn) !== -1) { if (benchmark.buttons.indexOf(DetectChangesBtn) !== -1) {
it('should work for detectChanges', (done) => { it('should work for detectChanges', (done: any) => {
runTreeBenchmark({ runTreeBenchmark({
id: 'detectChanges', id: 'detectChanges',
benchmark, benchmark,

10
modules/types.d.ts vendored
View File

@ -8,11 +8,11 @@
// This file contains all ambient imports needed to compile the modules/ source code // This file contains all ambient imports needed to compile the modules/ source code
/// <reference path="../node_modules/@types/hammerjs/index.d.ts" /> /// <reference types="hammerjs" />
/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> /// <reference types="jasmine" />
/// <reference path="../node_modules/@types/jasminewd2/index.d.ts" /> /// <reference types="jasminewd2" />
/// <reference path="../node_modules/@types/node/index.d.ts" /> /// <reference types="node" />
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" /> /// <reference types="zone.js" />
/// <reference path="../tools/types-ext/jasminewd2.d.ts" /> /// <reference path="../tools/types-ext/jasminewd2.d.ts" />
/// <reference path="./es6-subset.d.ts" /> /// <reference path="./es6-subset.d.ts" />
/// <reference path="./system.d.ts" /> /// <reference path="./system.d.ts" />

View File

@ -21,7 +21,8 @@
"prebuildifier": "bazel build --noshow_progress @com_github_bazelbuild_buildtools//buildifier", "prebuildifier": "bazel build --noshow_progress @com_github_bazelbuild_buildtools//buildifier",
"buildifier": "find . -type f \\( -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs $(bazel info bazel-bin)/external/com_github_bazelbuild_buildtools/buildifier/*/buildifier", "buildifier": "find . -type f \\( -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs $(bazel info bazel-bin)/external/com_github_bazelbuild_buildtools/buildifier/*/buildifier",
"preinstall": "node tools/yarn/check-yarn.js", "preinstall": "node tools/yarn/check-yarn.js",
"postinstall": "yarn update-webdriver && node ./tools/postinstall-patches.js", "postinstall": "yarn update-webdriver && node ./tools/postinstall-patches.js && yarn patch-types",
"patch-types": "mkdir -p node_modules/@types/zone.js && cp -f node_modules/zone.js/dist/zone.js.d.ts node_modules/@types/zone.js/index.d.ts",
"update-webdriver": "webdriver-manager update --gecko false $CHROMEDRIVER_VERSION_ARG", "update-webdriver": "webdriver-manager update --gecko false $CHROMEDRIVER_VERSION_ARG",
"check-env": "gulp check-env", "check-env": "gulp check-env",
"commitmsg": "node ./scripts/git/commit-msg.js" "commitmsg": "node ./scripts/git/commit-msg.js"

View File

@ -207,6 +207,12 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
if (fileName === if (fileName ===
path.join(compilerOpts.baseUrl, bazelOpts.package, compilerOpts.flatModuleOutFile + '.ts')) path.join(compilerOpts.baseUrl, bazelOpts.package, compilerOpts.flatModuleOutFile + '.ts'))
return true; return true;
// Also handle the case when angular is build from source as an external repository
if (fileName ===
path.join(
compilerOpts.baseUrl, 'external/angular', bazelOpts.package,
compilerOpts.flatModuleOutFile + '.ts'))
return true;
return origBazelHostShouldNameModule(fileName) || NGC_GEN_FILES.test(fileName); return origBazelHostShouldNameModule(fileName) || NGC_GEN_FILES.test(fileName);
}; };

View File

@ -70,7 +70,7 @@ export function createTsConfig(options: TsConfigOptions) {
'tsickleExternsPath': '', 'tsickleExternsPath': '',
// we don't copy the node_modules into our tmp dir, so we should look in // we don't copy the node_modules into our tmp dir, so we should look in
// the original workspace directory for it // the original workspace directory for it
'nodeModulesPrefix': '../angular/node_modules', 'nodeModulesPrefix': '../angular/external/angular_deps/node_modules',
}, },
'files': options.files, 'files': options.files,
'angularCompilerOptions': { 'angularCompilerOptions': {

View File

@ -21,7 +21,7 @@ ts_library(
], ],
), ),
module_name = "@angular/compiler-cli", module_name = "@angular/compiler-cli",
node_modules = "@//:node_modules", node_modules = "@angular_deps//:node_modules",
tsconfig = ":tsconfig", tsconfig = ":tsconfig",
deps = [ deps = [
"//packages/compiler", "//packages/compiler",

View File

@ -124,7 +124,8 @@ export function setupBazelTo(basePath: string) {
} }
// Link typescript // Link typescript
const typescriptSource = path.join(sources, 'angular/node_modules/typescript'); const typescriptSource =
path.join(sources, 'angular/external/angular_deps/node_modules/typescript');
const typescriptDest = path.join(nodeModulesPath, 'typescript'); const typescriptDest = path.join(nodeModulesPath, 'typescript');
if (fs.existsSync(typescriptSource)) { if (fs.existsSync(typescriptSource)) {
fs.symlinkSync(typescriptSource, typescriptDest); fs.symlinkSync(typescriptSource, typescriptDest);

View File

@ -8,12 +8,13 @@
import {ParseLocation, ParseSourceFile, ParseSourceSpan} from '@angular/compiler'; import {ParseLocation, ParseSourceFile, ParseSourceSpan} from '@angular/compiler';
import * as o from '@angular/compiler/src/output/output_ast'; import * as o from '@angular/compiler/src/output/output_ast';
import {MappingItem, RawSourceMap, SourceMapConsumer} from 'source-map';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {TypeScriptNodeEmitter} from '../../src/transformers/node_emitter'; import {TypeScriptNodeEmitter} from '../../src/transformers/node_emitter';
import {Directory, MockAotContext, MockCompilerHost} from '../mocks'; import {Directory, MockAotContext, MockCompilerHost} from '../mocks';
const sourceMap = require('source-map');
const someGenFilePath = '/somePackage/someGenFile'; const someGenFilePath = '/somePackage/someGenFile';
const someGenFileName = someGenFilePath + '.ts'; const someGenFileName = someGenFilePath + '.ts';
const someSourceFilePath = '/somePackage/someSourceFile'; const someSourceFilePath = '/somePackage/someSourceFile';
@ -469,16 +470,16 @@ describe('TypeScriptNodeEmitter', () => {
return result; return result;
} }
function mappingItemsOf(text: string): MappingItem[] { function mappingItemsOf(text: string) {
// find the source map: // find the source map:
const sourceMapMatch = /sourceMappingURL\=data\:application\/json;base64,(.*)$/.exec(text); const sourceMapMatch = /sourceMappingURL\=data\:application\/json;base64,(.*)$/.exec(text);
const sourceMapBase64 = sourceMapMatch ![1]; const sourceMapBase64 = sourceMapMatch ![1];
const sourceMapBuffer = Buffer.from(sourceMapBase64, 'base64'); const sourceMapBuffer = Buffer.from(sourceMapBase64, 'base64');
const sourceMapText = sourceMapBuffer.toString('utf8'); const sourceMapText = sourceMapBuffer.toString('utf8');
const sourceMap: RawSourceMap = JSON.parse(sourceMapText); const sourceMapParsed = JSON.parse(sourceMapText);
const consumer = new SourceMapConsumer(sourceMap); const consumer = new sourceMap.SourceMapConsumer(sourceMapParsed);
const mappings: MappingItem[] = []; const mappings: any[] = [];
consumer.eachMapping(mapping => { mappings.push(mapping); }); consumer.eachMapping((mapping: any) => { mappings.push(mapping); });
return mappings; return mappings;
} }

View File

@ -3134,6 +3134,9 @@
{ {
"name": "isIdentifierStart" "name": "isIdentifierStart"
}, },
{
"name": "isInteropObservable"
},
{ {
"name": "isIterable" "name": "isIterable"
}, },
@ -3167,9 +3170,6 @@
{ {
"name": "isObject" "name": "isObject"
}, },
{
"name": "isObservable"
},
{ {
"name": "isPrefixEnd" "name": "isPrefixEnd"
}, },

View File

@ -76,7 +76,7 @@ js_expected_symbol_test(
genrule( genrule(
name = "tslib", name = "tslib",
srcs = [ srcs = [
"//:node_modules/tslib/tslib.js", "@angular_deps//:node_modules/tslib/tslib.js",
], ],
outs = [ outs = [
"tslib.js", "tslib.js",

View File

@ -24,10 +24,10 @@ filegroup(
name = "elements_test_bootstrap_scripts", name = "elements_test_bootstrap_scripts",
# do not sort # do not sort
srcs = [ srcs = [
"//:node_modules/@webcomponents/custom-elements/src/native-shim.js", "@angular_deps//:node_modules/@webcomponents/custom-elements/src/native-shim.js",
"//:node_modules/reflect-metadata/Reflect.js", "@angular_deps//:node_modules/reflect-metadata/Reflect.js",
"//:node_modules/zone.js/dist/zone.js", "@angular_deps//:node_modules/zone.js/dist/zone.js",
"//:node_modules/zone.js/dist/zone-testing.js", "@angular_deps//:node_modules/zone.js/dist/zone-testing.js",
], ],
) )
@ -38,7 +38,7 @@ ts_web_test_suite(
], ],
# do not sort # do not sort
deps = [ deps = [
"//:node_modules/tslib/tslib.js", "@angular_deps//:node_modules/tslib/tslib.js",
"//tools/testing:browser", "//tools/testing:browser",
":test_lib", ":test_lib",
], ],

10
packages/types.d.ts vendored
View File

@ -6,12 +6,12 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
// This file contains all ambient imports needed to compile the modules/ source code // This file contains all ambient imports needed to compile the packages/ source code
/// <reference path="../node_modules/@types/hammerjs/index.d.ts" /> /// <reference types="hammerjs" />
/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> /// <reference types="jasmine" />
/// <reference path="../node_modules/@types/node/index.d.ts" /> /// <reference types="node" />
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" /> /// <reference types="zone.js" />
/// <reference path="./es6-subset.d.ts" /> /// <reference path="./es6-subset.d.ts" />
/// <reference path="./goog.d.ts" /> /// <reference path="./goog.d.ts" />
/// <reference path="./system.d.ts" /> /// <reference path="./system.d.ts" />

View File

@ -55,7 +55,7 @@ export function createWithEachNg1VersionFn(setNg1: typeof setAngularJSGlobal) {
(prev, file) => prev.then(() => new Promise<void>((resolve, reject) => { (prev, file) => prev.then(() => new Promise<void>((resolve, reject) => {
const restoreMethods = patchJasmineMethods(); const restoreMethods = patchJasmineMethods();
const script = document.createElement('script'); const script = document.createElement('script');
script.src = `base/angular/node_modules/${file}`; script.src = `base/angular_deps/node_modules/${file}`;
script.onerror = reject; script.onerror = reject;
script.onload = () => { script.onload = () => {
document.body.removeChild(script); document.body.removeChild(script);

View File

@ -5,6 +5,7 @@ load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_p
load("//packages/bazel/src:ng_module.bzl", _internal_global_ng_module = "internal_global_ng_module") load("//packages/bazel/src:ng_module.bzl", _internal_global_ng_module = "internal_global_ng_module")
DEFAULT_TSCONFIG = "//packages:tsconfig-build.json" DEFAULT_TSCONFIG = "//packages:tsconfig-build.json"
DEFAULT_NODE_MODULES = "@angular_deps//:node_modules"
# Packages which are versioned together on npm # Packages which are versioned together on npm
ANGULAR_SCOPED_PACKAGES = ["@angular/%s" % p for p in [ ANGULAR_SCOPED_PACKAGES = ["@angular/%s" % p for p in [
@ -37,17 +38,17 @@ PKG_GROUP_REPLACEMENTS = {
]""" % ",\n ".join(["\"%s\"" % s for s in ANGULAR_SCOPED_PACKAGES]) ]""" % ",\n ".join(["\"%s\"" % s for s in ANGULAR_SCOPED_PACKAGES])
} }
def ts_library(tsconfig = None, **kwargs): def ts_library(tsconfig = None, node_modules = DEFAULT_NODE_MODULES, **kwargs):
if not tsconfig: if not tsconfig:
tsconfig = DEFAULT_TSCONFIG tsconfig = DEFAULT_TSCONFIG
_ts_library(tsconfig = tsconfig, **kwargs) _ts_library(tsconfig = tsconfig, node_modules = node_modules, **kwargs)
def ng_module(name, tsconfig = None, entry_point = None, **kwargs): def ng_module(name, tsconfig = None, entry_point = None, node_modules = DEFAULT_NODE_MODULES, **kwargs):
if not tsconfig: if not tsconfig:
tsconfig = DEFAULT_TSCONFIG tsconfig = DEFAULT_TSCONFIG
if not entry_point: if not entry_point:
entry_point = "public_api.ts" entry_point = "public_api.ts"
_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, **kwargs) _ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, node_modules = node_modules, **kwargs)
# ivy_ng_module behaves like ng_module, and under --define=compile=legacy it runs ngc with global # ivy_ng_module behaves like ng_module, and under --define=compile=legacy it runs ngc with global
# analysis but produces Ivy outputs. Under other compile modes, it behaves as ng_module. # analysis but produces Ivy outputs. Under other compile modes, it behaves as ng_module.
@ -82,7 +83,7 @@ def ts_web_test_suite(bootstrap = [], deps = [], **kwargs):
if not bootstrap: if not bootstrap:
bootstrap = ["//:web_test_bootstrap_scripts"] bootstrap = ["//:web_test_bootstrap_scripts"]
local_deps = [ local_deps = [
"//:node_modules/tslib/tslib.js", "@angular_deps//:node_modules/tslib/tslib.js",
"//tools/testing:browser", "//tools/testing:browser",
] + deps ] + deps

View File

@ -0,0 +1,238 @@
# 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
"Install angular source dependencies"
load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")
load("@angular//packages/bazel/src:ng_setup_workspace.bzl", _ng_setup_workspace = "ng_setup_workspace")
def ng_setup_workspace():
"""This repository rule should be called from your WORKSPACE file.
It creates some additional Bazel external repositories that are used internally
to build angular
"""
yarn_install(
name = "angular_deps",
package_json = "@angular//:package.json",
yarn_lock = "@angular//:yarn.lock",
data = ["@angular//:tools/yarn/check-yarn.js", "@angular//:tools/postinstall-patches.js"],
node_modules_filegroup = """
filegroup(
name = "node_modules",
srcs = glob(["/".join([
"node_modules",
pkg,
"**",
ext,
]) for pkg in [
"adm-zip",
"ajv",
"angular",
"angular-1.5",
"angular-mocks",
"angular-mocks-1.5",
"anymatch",
"arr-diff",
"arr-flatten",
"arr-union",
"array-unique",
"asn1",
"assert-plus",
"assign-symbols",
"async-each",
"asynckit",
"atob",
"aws-sign2",
"aws4",
"balanced-match",
"base",
"base64-js",
"binary-extensions",
"blocking-proxy",
"brace-expansion",
"braces",
"bytebuffer",
"cache-base",
"caseless",
"chokidar",
"class-utils",
"co",
"collection-visit",
"combined-stream",
"component-emitter",
"concat-map",
"copy-descriptor",
"core-util-is",
"debug",
"decode-uri-component",
"define-property",
"delayed-stream",
"domino",
"expand-brackets",
"expand-range",
"extend",
"extend-shallow",
"extglob",
"extsprintf",
"fast-deep-equal",
"fast-json-stable-stringify",
"filename-regex",
"fill-range",
"for-in",
"for-own",
"forever-agent",
"form-data",
"fragment-cache",
"fs.realpath",
"get-value",
"glob",
"glob-base",
"glob-parent",
"graceful-fs",
"hammerjs",
"har-schema",
"har-validator",
"has-value",
"has-values",
"http-signature",
"https-proxy-agent",
"inflight",
"inherits",
"is-accessor-descriptor",
"is-binary-path",
"is-buffer",
"is-data-descriptor",
"is-descriptor",
"is-dotfile",
"is-equal-shallow",
"is-extendable",
"is-extglob",
"is-glob",
"is-number",
"is-plain-object",
"is-posix-bracket",
"is-primitive",
"is-typedarray",
"is-windows",
"isarray",
"isobject",
"isstream",
"jasmine",
"jasmine-core",
"jasminewd2",
"json-schema",
"json-schema-traverse",
"json-stable-stringify",
"json-stringify-safe",
"jsprim",
"kind-of",
"long",
"lru-cache",
"map-cache",
"map-visit",
"math-random",
"micromatch",
"mime-db",
"mime-types",
"minimatch",
"minimist",
"mixin-deep",
"nanomatch",
"normalize-path",
"oauth-sign",
"object.omit",
"object.pick",
"object-copy",
"object-visit",
"once",
"optimist",
"options",
"os-tmpdir",
"parse-glob",
"pascalcase",
"path-dirname",
"path-is-absolute",
"performance-now",
"posix-character-classes",
"preserve",
"process-nextick-args",
"protobufjs",
"protractor",
"qs",
"randomatic",
"readable-stream",
"readdirp",
"reflect-metadata",
"regex-cache",
"regex-not",
"remove-trailing-separator",
"repeat-element",
"repeat-string",
"request",
"ret",
"rimraf",
"safe-buffer",
"safe-regex",
"safer-buffer",
"sax",
"semver",
"set-immediate-shim",
"set-value",
"shelljs",
"sigmund",
"snapdragon",
"snapdragon-node",
"snapdragon-util",
"source-map",
"source-map-resolve",
"source-map-support",
"source-map-url",
"split-string",
"sshpk",
"static-extend",
"stringstream",
"tmp",
"to-object-path",
"to-regex",
"to-regex-range",
"tough-cookie",
"tsickle",
"tslib",
"tsutils",
"tunnel-agent",
"typescript",
"union-value",
"unset-value",
"upath",
"uri-js",
"urix",
"use",
"util-deprecate",
"uuid",
"verror",
"webdriver-js-extender",
"webdriver-manager",
"wordwrap",
"wrappy",
"xhr2",
"xml2js",
"xmlbuilder",
"zone.js",
"@angular-devkit/core",
"@angular-devkit/schematics",
"@types",
"@webcomponents/custom-elements",
] for ext in [
"*.js",
"*.json",
"*.d.ts",
]] + [
"node_modules/protractor/**",
"node_modules/@schematics/angular/**",
]))
""")
_ng_setup_workspace()

View File

@ -6,6 +6,19 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
try {
require.resolve('shelljs');
} catch (e) {
// We are in an bazel managed external node_modules repository
// and the resolve has failed because node did not preserve the symlink
// when loading the script.
// This can be fixed using the --preserve-symlinks-main flag which
// is introduced in node 10.2.0
console.warn(
'Running postinstall-patches.js script in an external repository requires --preserve-symlinks-main node flag introduced in node 10.2.0');
process.exit(0);
}
const {set, cd, sed, rm} = require('shelljs'); const {set, cd, sed, rm} = require('shelljs');
const path = require('path'); const path = require('path');
const log = console.log; const log = console.log;

6
tools/types.d.ts vendored
View File

@ -1,5 +1,5 @@
// This file contains all ambient imports needed to compile the tools source code // This file contains all ambient imports needed to compile the tools source code
/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> /// <reference types="jasmine" />
/// <reference path="../node_modules/@types/node/index.d.ts" /> /// <reference types="node" />
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" /> /// <reference types="zone.js" />

1682
yarn.lock

File diff suppressed because it is too large Load Diff