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 514d03f2d0
commit 8743a9bfd6
25 changed files with 1231 additions and 1125 deletions

View File

@ -207,6 +207,12 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true,
if (fileName ===
path.join(compilerOpts.baseUrl, bazelOpts.package, compilerOpts.flatModuleOutFile + '.ts'))
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);
};

View File

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

View File

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

View File

@ -124,7 +124,8 @@ export function setupBazelTo(basePath: string) {
}
// 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');
if (fs.existsSync(typescriptSource)) {
fs.symlinkSync(typescriptSource, typescriptDest);

View File

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

View File

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

View File

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

View File

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

10
packages/types.d.ts vendored
View File

@ -6,12 +6,12 @@
* 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 path="../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../node_modules/@types/node/index.d.ts" />
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts" />
/// <reference types="hammerjs" />
/// <reference types="jasmine" />
/// <reference types="node" />
/// <reference types="zone.js" />
/// <reference path="./es6-subset.d.ts" />
/// <reference path="./goog.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) => {
const restoreMethods = patchJasmineMethods();
const script = document.createElement('script');
script.src = `base/angular/node_modules/${file}`;
script.src = `base/angular_deps/node_modules/${file}`;
script.onerror = reject;
script.onload = () => {
document.body.removeChild(script);