refactor: update paths from modules/@angular to packages

This commit is contained in:
Jason Aden
2017-03-07 11:04:30 -08:00
parent da8ea350b2
commit b74ab83d2c
53 changed files with 232 additions and 104 deletions

View File

@ -27,5 +27,5 @@
"bugs": {
"url": "https://github.com/angular/angular/issues"
},
"homepage": "https://github.com/angular/angular/tree/master/modules/@angular/compiler-cli"
"homepage": "https://github.com/angular/angular/tree/master/packages/compiler-cli"
}

View File

@ -4,7 +4,7 @@ set -ex
cd $(dirname $0)/../../..
ROOTDIR=$(pwd)
SRCDIR=${ROOTDIR}/modules/@angular/benchpress
SRCDIR=${ROOTDIR}/packages/benchpress
DESTDIR=${ROOTDIR}/dist/packages-dist/benchpress
rm -fr ${DESTDIR}

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/testing.d.ts",
"typings": "../typings/testing/index.d.ts",
"main": "../bundles/common-testing.umd.js",
"module": "../@angular/common/testing.es5.js",
"es2015": "../@angular/common/testing.js"

View File

@ -128,11 +128,11 @@ $ cp tools/@angular/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped
$ ./scripts/ci/offline_compiler_test.sh
# Keep a package fresh in watch mode
./node_modules/.bin/tsc -p modules/@angular/compiler/tsconfig-es5.json -w
./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/tsc-wrapped/src/main -p modules/@angular/core/tsconfig-es5.json
$ node dist/tools/@angular/tsc-wrapped/src/main -p packages/core/tsconfig-build.json
# Iterate on the test
$ cd /tmp/wherever/e2e_test.1464388257/

View File

@ -34,5 +34,5 @@
"bugs": {
"url": "https://github.com/angular/angular/issues"
},
"homepage": "https://github.com/angular/angular/tree/master/modules/@angular/compiler-cli"
"homepage": "https://github.com/angular/angular/tree/master/packages/compiler-cli"
}

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/testing.d.ts",
"typings": "../typings/testing/index.d.ts",
"main": "../bundles/compiler-testing.umd.js",
"module": "../@angular/compiler/testing.es5.js",
"es2015": "../@angular/compiler/testing.js"

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/testing.d.ts",
"typings": "../typings/testing/index.d.ts",
"main": "../bundles/core-testing.umd.js",
"module": "../@angular/core/testing.es5.js",
"es2015": "../@angular/core/testing.js"

View File

@ -54,12 +54,12 @@ interface NumberConstructor {
// Workaround https://github.com/Microsoft/TypeScript/issues/9193
interface PromiseConstructor {
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
all<T>(values: (T|PromiseLike<T>)[]): Promise<T[]>;
}
interface Function {
/**
* Returns the name of the function. Function names are read-only and can not be changed.
*/
readonly name: string;
/**
* Returns the name of the function. Function names are read-only and can not be changed.
*/
readonly name: string;
}

View File

@ -11,7 +11,7 @@ behavior) just like an Angular application developer would write.
./build.sh
# run when test change
./modules/@angular/examples/build.sh
./packages/examples/build.sh
# start server
$(npm bin)/gulp serve-examples
@ -26,7 +26,7 @@ navigate to [http://localhost:8001](http://localhost:8001)
./build.sh
# run to compile tests and run them
./modules/@angular/examples/test.sh
./packages/examples/test.sh
```
NOTE: sometimes the http server does not exit properly and it retains the `8001` port.

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/testing.d.ts",
"typings": "../typings/testing/index.d.ts",
"main": "../bundles/http-testing.umd.js",
"module": "../@angular/http/testing.es5.js",
"es2015": "../@angular/http/testing.js"

View File

@ -24,7 +24,7 @@ var esm_suffixes = {};
function normalize(fileName) {
return path.resolve(__dirname, fileName);
}
console.log('running')
function resolve(id, from) {
// console.log('Resolve id:', id, 'from', from)
if (id == '@angular/tsc-wrapped') {
@ -37,7 +37,8 @@ function resolve(id, from) {
var packageName = match[1];
var esm_suffix = esm_suffixes[packageName] || '';
var loc = locations[packageName] || location;
var r = loc !== location && (loc + esm_suffix + packageName + (match[3] || '/index') + '.js') || loc + packageName + '/@angular/' + packageName + '.es5.js';
var r = loc !== location && (loc + esm_suffix + packageName + (match[3] || '/index') + '.js') ||
loc + packageName + '/@angular/' + packageName + '.es5.js';
// console.log('** ANGULAR MAPPED **: ', r);
return r;
}

View File

@ -6,9 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference path="../../../node_modules/@types/node/index.d.ts" />
/// <reference path="../../../node_modules/@types/jasmine/index.d.ts" />
import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';

View File

@ -7,7 +7,8 @@
*/
export default {
entry: '../../dist/packages-dist/platform-browser-dynamic/@angular/platform-browser-dynamic.es5.js',
entry:
'../../dist/packages-dist/platform-browser-dynamic/@angular/platform-browser-dynamic.es5.js',
dest: '../../dist/packages-dist/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
format: 'umd',
moduleName: 'ng.platformBrowserDynamic',

View File

@ -19,7 +19,7 @@ export function main() {
// will be relative to here, so url200 should look like
// static_assets/200.html.
// We currently have no way of detecting this.
const url200 = '/base/modules/@angular/platform-browser/test/browser/static_assets/200.html';
const url200 = '/base/packages/platform-browser/test/browser/static_assets/200.html';
const url404 = '/bad/path/404.html';
beforeEach(() => { resourceLoader = new ResourceLoaderImpl(); });

View File

@ -26,7 +26,7 @@ class FancyService {
@Component({
selector: 'external-template-comp',
templateUrl: '/base/modules/@angular/platform-browser/test/static_assets/test.html'
templateUrl: '/base/packages/platform-browser/test/static_assets/test.html'
})
class ExternalTemplateComp {
}
@ -48,8 +48,7 @@ export function main() {
it('should run async tests with ResourceLoaders', async(() => {
const resourceLoader = new ResourceLoaderImpl();
resourceLoader
.get('/base/modules/@angular/platform-browser/test/static_assets/test.html')
resourceLoader.get('/base/packages/platform-browser/test/static_assets/test.html')
.then(() => { actuallyDone = true; });
}),
10000); // Long timeout here because this test makes an actual ResourceLoader.

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/testing.d.ts",
"typings": "../typings/testing/index.d.ts",
"main": "../bundles/platform-browser-dynamic-testing.umd.js",
"module": "../@angular/platform-browser-dynamic/testing.es5.js",
"es2015": "../@angular/platform-browser-dynamic/testing.js"

View File

@ -7,7 +7,8 @@
*/
export default {
entry: '../../../dist/packages-dist/platform-browser-dynamic/@angular/platform-browser-dynamic/testing.es5.js',
entry:
'../../../dist/packages-dist/platform-browser-dynamic/@angular/platform-browser-dynamic/testing.es5.js',
dest:
'../../../dist/packages-dist/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
format: 'umd',

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/animations.d.ts",
"typings": "../typings/animations/index.d.ts",
"main": "../bundles/platform-browser-animations.umd.js",
"module": "../@angular/platform-browser/animations.es5.js",
"es2015": "../@angular/platform-browser/animations.js"

View File

@ -7,8 +7,10 @@
*/
export default {
entry: '../../../../dist/packages-dist/platform-browser/@angular/platform-browser/animations/testing.es5.js',
dest: '../../../../dist/packages-dist/platform-browser/bundles/platform-browser-animations-testing.umd.js',
entry:
'../../../../dist/packages-dist/platform-browser/@angular/platform-browser/animations/testing.es5.js',
dest:
'../../../../dist/packages-dist/platform-browser/bundles/platform-browser-animations-testing.umd.js',
format: 'umd',
moduleName: 'ng.platformBrowser.testing',
globals: {

View File

@ -103,10 +103,8 @@ class CompUsingModuleDirectiveAndPipe {
class SomeLibModule {
}
@Component({
selector: 'comp',
templateUrl: '/base/modules/@angular/platform-browser/test/static_assets/test.html'
})
@Component(
{selector: 'comp', templateUrl: '/base/packages/platform-browser/test/static_assets/test.html'})
class CompWithUrlTemplate {
}

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/testing.d.ts",
"typings": "../typings/testing/index.d.ts",
"main": "../bundles/platform-browser-testing.umd.js",
"module": "../@angular/platform-browser/testing.es5.js",
"es2015": "../@angular/platform-browser/testing.js"

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/testing.d.ts",
"typings": "../typings/testing/index.d.ts",
"main": "../bundles/platform-server-testing.umd.js",
"module": "../@angular/platform-server/testing.es5.js",
"es2015": "../@angular/platform-server/testing.js"

View File

@ -7,7 +7,8 @@
*/
export default {
entry: '../../dist/packages-dist/platform-webworker-dynamic/@angular/platform-webworker-dynamic.es5.js',
entry:
'../../dist/packages-dist/platform-webworker-dynamic/@angular/platform-webworker-dynamic.es5.js',
dest:
'../../dist/packages-dist/platform-webworker-dynamic/bundles/platform-webworker-dynamic.umd.js',
format: 'umd',

View File

@ -40,7 +40,7 @@ module.exports = function(config) {
{pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false},
// shim
{pattern: 'modules/@angular/router/karma-test-shim.js', included: true, watched: true},
{pattern: 'packages/router/karma-test-shim.js', included: true, watched: true},
// Angular modules
{pattern: 'dist/all/@angular/core/*.js', included: false, watched: false},

View File

@ -0,0 +1,244 @@
/**
* @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
*/
import {APP_BASE_HREF} from '@angular/common';
import {ApplicationRef, CUSTOM_ELEMENTS_SCHEMA, Component, NgModule, destroyPlatform} from '@angular/core';
import {inject} from '@angular/core/testing';
import {BrowserModule, DOCUMENT, ɵgetDOM as getDOM} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {NavigationEnd, Resolve, Router, RouterModule} from '@angular/router';
describe('bootstrap', () => {
let log: any[] = [];
let testProviders: any[] = null;
@Component({selector: 'test-app', template: 'root <router-outlet></router-outlet>'})
class RootCmp {
constructor() { log.push('RootCmp'); }
}
@Component({selector: 'test-app2', template: 'root <router-outlet></router-outlet>'})
class SecondRootCmp {
}
class TestResolver implements Resolve<any> {
resolve() {
let resolve: any = null;
const res = new Promise(r => resolve = r);
setTimeout(() => resolve('test-data'), 0);
return res;
}
}
beforeEach(inject([DOCUMENT], (doc: any) => {
destroyPlatform();
const el1 = getDOM().createElement('test-app', doc);
const el2 = getDOM().createElement('test-app2', doc);
getDOM().appendChild(doc.body, el1);
getDOM().appendChild(doc.body, el2);
log = [];
testProviders = [{provide: APP_BASE_HREF, useValue: ''}];
}));
afterEach(inject([DOCUMENT], (doc: any) => {
const oldRoots = getDOM().querySelectorAll(doc, 'test-app,test-app2');
for (let i = 0; i < oldRoots.length; i++) {
getDOM().remove(oldRoots[i]);
}
}));
it('should wait for resolvers to complete when initialNavigation = enabled', (done) => {
@Component({selector: 'test', template: 'test'})
class TestCmpEnabled {
}
@NgModule({
imports: [
BrowserModule, RouterModule.forRoot(
[{path: '**', component: TestCmpEnabled, resolve: {test: TestResolver}}],
{useHash: true, initialNavigation: 'enabled'})
],
declarations: [RootCmp, TestCmpEnabled],
bootstrap: [RootCmp],
providers: [...testProviders, TestResolver],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
class TestModule {
constructor(router: Router) {
log.push('TestModule');
router.events.subscribe(e => log.push(e.constructor.name));
}
}
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
const router = res.injector.get(Router);
const data = router.routerState.snapshot.root.firstChild.data;
expect(data['test']).toEqual('test-data');
expect(log).toEqual(
['TestModule', 'NavigationStart', 'RoutesRecognized', 'RootCmp', 'NavigationEnd']);
done();
});
});
it('should NOT wait for resolvers to complete when initialNavigation = legacy_enabled',
(done) => {
@Component({selector: 'test', template: 'test'})
class TestCmpLegacyEnabled {
}
@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot(
[{path: '**', component: TestCmpLegacyEnabled, resolve: {test: TestResolver}}],
{useHash: true, initialNavigation: 'legacy_enabled'})
],
declarations: [RootCmp, TestCmpLegacyEnabled],
bootstrap: [RootCmp],
providers: [...testProviders, TestResolver],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
class TestModule {
constructor(router: Router) {
log.push('TestModule');
router.events.subscribe(e => log.push(e.constructor.name));
}
}
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
const router = res.injector.get(Router);
expect(router.routerState.snapshot.root.firstChild).toBeNull();
// NavigationEnd has not been emitted yet because bootstrap returned too early
expect(log).toEqual(['TestModule', 'RootCmp', 'NavigationStart', 'RoutesRecognized']);
router.events.subscribe((e) => {
if (e instanceof NavigationEnd) {
done();
}
});
});
});
it('should not run navigation when initialNavigation = disabled', (done) => {
@Component({selector: 'test', template: 'test'})
class TestCmpDiabled {
}
@NgModule({
imports: [
BrowserModule, RouterModule.forRoot(
[{path: '**', component: TestCmpDiabled, resolve: {test: TestResolver}}],
{useHash: true, initialNavigation: 'disabled'})
],
declarations: [RootCmp, TestCmpDiabled],
bootstrap: [RootCmp],
providers: [...testProviders, TestResolver],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
class TestModule {
constructor(router: Router) {
log.push('TestModule');
router.events.subscribe(e => log.push(e.constructor.name));
}
}
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
const router = res.injector.get(Router);
expect(log).toEqual(['TestModule', 'RootCmp']);
done();
});
});
it('should not run navigation when initialNavigation = legacy_disabled', (done) => {
@Component({selector: 'test', template: 'test'})
class TestCmpLegacyDisabled {
}
@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot(
[{path: '**', component: TestCmpLegacyDisabled, resolve: {test: TestResolver}}],
{useHash: true, initialNavigation: 'legacy_disabled'})
],
declarations: [RootCmp, TestCmpLegacyDisabled],
bootstrap: [RootCmp],
providers: [...testProviders, TestResolver],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
class TestModule {
constructor(router: Router) {
log.push('TestModule');
router.events.subscribe(e => log.push(e.constructor.name));
}
}
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
const router = res.injector.get(Router);
expect(log).toEqual(['TestModule', 'RootCmp']);
done();
});
});
it('should not init router navigation listeners if a non root component is bootstrapped',
(done) => {
@NgModule({
imports: [BrowserModule, RouterModule.forRoot([], {useHash: true})],
declarations: [SecondRootCmp, RootCmp],
entryComponents: [SecondRootCmp],
bootstrap: [RootCmp],
providers: testProviders,
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
class TestModule {
}
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
const router = res.injector.get(Router);
spyOn(router, 'resetRootComponentType').and.callThrough();
const appRef: ApplicationRef = res.injector.get(ApplicationRef);
appRef.bootstrap(SecondRootCmp);
expect(router.resetRootComponentType).not.toHaveBeenCalled();
done();
});
});
it('should reinit router navigation listeners if a previously bootstrapped root component is destroyed',
(done) => {
@NgModule({
imports: [BrowserModule, RouterModule.forRoot([], {useHash: true})],
declarations: [SecondRootCmp, RootCmp],
entryComponents: [SecondRootCmp],
bootstrap: [RootCmp],
providers: testProviders,
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
class TestModule {
}
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
const router = res.injector.get(Router);
spyOn(router, 'resetRootComponentType').and.callThrough();
const appRef: ApplicationRef = res.injector.get(ApplicationRef);
appRef.components[0].onDestroy(() => {
appRef.bootstrap(SecondRootCmp);
expect(router.resetRootComponentType).toHaveBeenCalled();
done();
});
appRef.components[0].destroy();
});
});
});

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/testing.d.ts",
"typings": "../typings/testing/index.d.ts",
"main": "../bundles/router-testing.umd.js",
"module": "../@angular/router/testing.es5.js",
"es2015": "../@angular/router/testing.js"

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/upgrade.d.ts",
"typings": "../typings/upgrade/index.d.ts",
"main": "../bundles/router-upgrade.umd.js",
"module": "../@angular/router/upgrade.es5.js",
"es2015": "../@angular/router/upgrade.js"

View File

@ -6,7 +6,7 @@
"emitDecoratorMetadata": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../dist/all/",
"outDir": "../dist/all/@angular",
"noImplicitAny": true,
"noFallthroughCasesInSwitch": true,
"paths": {
@ -26,13 +26,6 @@
"types": ["angularjs"]
},
"exclude": [
"angular1_router",
"benchmarks/e2e_test/old",
"benchmarks/src/old",
"benchmarks/src/**/index_aot.ts",
"benchmarks_external",
"payload_tests",
"rollup-test",
"compiler-cli/integrationtest"
]
}

View File

@ -1,5 +1,5 @@
{
"typings": "../typings/static.d.ts",
"typings": "../typings/static/index.d.ts",
"main": "../bundles/upgrade-static.umd.js",
"module": "../@angular/upgrade/static.es5.js",
"es2015": "../@angular/upgrade/static.js"