refactor(upgrade): re-export the new static upgrade APIs on new entry

Add upgrade-static.umd.js bundles
This allows depending on it without getting a transitive dependency on compiler.

BREAKING CHANGE:

Four newly added APIs in 2.2.0-beta:
downgradeComponent, downgradeInjectable, UpgradeComponent, and UpgradeModule
are no longer exported by @angular/upgrade.
Import these from @angular/upgrade/static instead.
This commit is contained in:
Alex Eagle 2016-10-20 19:35:35 -07:00 committed by vsavkin
parent 7742ec00e7
commit a26dd28bdb
18 changed files with 81 additions and 50 deletions

View File

@ -101,7 +101,9 @@ do
DESTDIR=${PWD}/dist/packages-dist/${PACKAGE}
UMD_ES5_PATH=${DESTDIR}/bundles/${PACKAGE}.umd.js
UMD_TESTING_ES5_PATH=${DESTDIR}/bundles/${PACKAGE}-testing.umd.js
UMD_STATIC_ES5_PATH=${DESTDIR}/bundles/${PACKAGE}-static.umd.js
UMD_ES5_MIN_PATH=${DESTDIR}/bundles/${PACKAGE}.umd.min.js
UMD_STATIC_ES5_MIN_PATH=${DESTDIR}/bundles/${PACKAGE}-static.umd.min.js
LICENSE_BANNER=${PWD}/modules/@angular/license-banner.txt
rm -rf ${DESTDIR}
@ -157,6 +159,18 @@ do
cat ${UMD_TESTING_ES5_PATH} >> ${UMD_TESTING_ES5_PATH}.tmp
mv ${UMD_TESTING_ES5_PATH}.tmp ${UMD_TESTING_ES5_PATH}
fi
if [[ -e rollup-static.config.js ]]; then
echo "====== Rollup ${PACKAGE} static"
../../../node_modules/.bin/rollup -c rollup-static.config.js
# create dir because it doesn't exist yet, we should move the src code here and remove this line
mkdir ${DESTDIR}/static
echo "{\"main\": \"../bundles/${PACKAGE}-static.umd.js\"}" > ${DESTDIR}/static/package.json
cat ${LICENSE_BANNER} > ${UMD_STATIC_ES5_PATH}.tmp
cat ${UMD_STATIC_ES5_PATH} >> ${UMD_STATIC_ES5_PATH}.tmp
mv ${UMD_STATIC_ES5_PATH}.tmp ${UMD_STATIC_ES5_PATH}
$UGLIFYJS -c --screw-ie8 --comments -o ${UMD_STATIC_ES5_MIN_PATH} ${UMD_STATIC_ES5_PATH}
fi
) 2>&1 | grep -v "as external dependency"
fi

View File

@ -58,6 +58,7 @@ const entrypoints = [
//'dist/packages-dist/compiler/index.d.ts',
//'dist/packages-dist/compiler/testing.d.ts',
'dist/packages-dist/upgrade/index.d.ts',
'dist/packages-dist/upgrade/static.d.ts',
'dist/packages-dist/platform-browser/index.d.ts',
'dist/packages-dist/platform-browser/testing/index.d.ts',
'dist/packages-dist/platform-browser-dynamic/index.d.ts',

View File

@ -12,5 +12,4 @@
* Entry point for all public APIs of the upgrade package.
*/
export * from './src/upgrade';
export * from './src/aot';
// This file only reexports content of the `src` folder. Keep it that way.

View File

@ -0,0 +1,15 @@
/**
* @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
*/
export default {
entry: '../../../dist/packages-dist/upgrade/static.js',
dest: '../../../dist/packages-dist/upgrade/bundles/upgrade-static.umd.js',
format: 'umd',
moduleName: 'ng.upgrade.static',
globals: {'@angular/core': 'ng.core'}
};

View File

@ -1,12 +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
*/
export {downgradeComponent} from './aot/downgrade_component';
export {downgradeInjectable} from './aot/downgrade_injectable';
export {UpgradeComponent} from './aot/upgrade_component';
export {UpgradeModule} from './aot/upgrade_module';

View File

@ -0,0 +1,13 @@
/**
* @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
*/
export {downgradeComponent} from './src/aot/downgrade_component';
export {downgradeInjectable} from './src/aot/downgrade_injectable';
export {UpgradeComponent} from './src/aot/upgrade_component';
export {UpgradeModule} from './src/aot/upgrade_module';
// This file only reexports content of the `src` folder. Keep it that way.

View File

@ -10,8 +10,8 @@ import {Component, Directive, ElementRef, Injector, NgModule, destroyPlatform} f
import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/angular_js';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import {bootstrap, html} from '../test_helpers';
@ -77,4 +77,4 @@ export function main() {
});
}));
});
}
}

View File

@ -10,8 +10,8 @@ import {Component, Directive, ElementRef, Injector, NgModule, destroyPlatform} f
import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/angular_js';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import {bootstrap, html} from '../test_helpers';

View File

@ -10,8 +10,8 @@ import {Component, EventEmitter, NgModule, OnChanges, OnDestroy, SimpleChanges,
import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeModule, downgradeComponent} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/angular_js';
import {UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import {bootstrap, html, multiTrim} from '../test_helpers';
@ -256,4 +256,4 @@ export function main() {
});
}));
});
}
}

View File

@ -10,8 +10,8 @@ import {Component, Directive, ElementRef, Injector, Input, NgModule, destroyPlat
import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/angular_js';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import {bootstrap, html, multiTrim} from '../test_helpers';
@ -86,4 +86,4 @@ export function main() {
});
}));
});
}
}

View File

@ -10,8 +10,8 @@ import {NgModule, OpaqueToken, destroyPlatform} from '@angular/core';
import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeModule, downgradeInjectable} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/angular_js';
import {UpgradeModule, downgradeInjectable} from '@angular/upgrade/static';
import {bootstrap, html} from '../test_helpers';
@ -77,4 +77,4 @@ export function main() {
});
}));
});
}
}

View File

@ -10,8 +10,8 @@ import {NgModule, Testability, destroyPlatform} from '@angular/core';
import {fakeAsync, tick} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeModule} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/angular_js';
import {UpgradeModule} from '@angular/upgrade/static';
import {bootstrap, html} from '../test_helpers';
@ -68,4 +68,4 @@ export function main() {
});
}));
});
}
}

View File

@ -10,8 +10,8 @@ import {Component, Directive, ElementRef, EventEmitter, Injector, Input, NO_ERRO
import {async, fakeAsync, tick} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/angular_js';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import {bootstrap, html, multiTrim} from '../test_helpers';
@ -1561,4 +1561,4 @@ export function main() {
// });
// }));
});
}
}

View File

@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PlatformRef, Type} from '@angular/core';
import {UpgradeModule} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/angular_js';
import {UpgradeModule} from '@angular/upgrade/static';
export function bootstrap(
platform: PlatformRef, Ng2Module: Type<{}>, element: Element, ng1Module: angular.IModule) {

View File

@ -23,6 +23,7 @@
},
"files": [
"index.ts",
"static.ts",
"../../../node_modules/zone.js/dist/zone.js.d.ts"
],
"angularCompilerOptions": {

View File

@ -39,6 +39,7 @@
'/packages-dist/platform-webworker-dynamic/bundles/platform-webworker-dynamic.umd.js',
'@angular/router': '/packages-dist/router/bundles/router.umd.js',
'@angular/upgrade': '/packages-dist/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': '/packages-dist/upgrade/bundles/upgrade-static.umd.js',
'rxjs': '/all/playground/vendor/rxjs',
// TODO(i): remove once playground apps no longer use facades directly

View File

@ -1,9 +1,3 @@
/** @experimental */
export declare function downgradeComponent(info: ComponentInfo): angular.IInjectable;
/** @experimental */
export declare function downgradeInjectable(token: any): (string | ((i: Injector) => any))[];
/** @stable */
export declare class UpgradeAdapter {
constructor(ng2AppModule: Type<any>, compilerOptions?: CompilerOptions);
@ -25,20 +19,3 @@ export declare class UpgradeAdapterRef {
dispose(): void;
ready(fn: (upgradeAdapterRef?: UpgradeAdapterRef) => void): void;
}
/** @experimental */
export declare class UpgradeComponent implements OnInit, OnChanges, DoCheck {
constructor(name: string, elementRef: ElementRef, injector: Injector);
ngDoCheck(): void;
ngOnChanges(changes: SimpleChanges): void;
ngOnInit(): void;
}
/** @experimental */
export declare class UpgradeModule {
$injector: angular.IInjectorService;
injector: Injector;
ngZone: NgZone;
constructor(injector: Injector, ngZone: NgZone);
bootstrap(element: Element, modules?: string[], config?: angular.IAngularBootstrapConfig): void;
}

View File

@ -0,0 +1,22 @@
/** @experimental */
export declare function downgradeComponent(info: ComponentInfo): angular.IInjectable;
/** @experimental */
export declare function downgradeInjectable(token: any): (string | ((i: Injector) => any))[];
/** @experimental */
export declare class UpgradeComponent implements OnInit, OnChanges, DoCheck {
constructor(name: string, elementRef: ElementRef, injector: Injector);
ngDoCheck(): void;
ngOnChanges(changes: SimpleChanges): void;
ngOnInit(): void;
}
/** @experimental */
export declare class UpgradeModule {
$injector: angular.IInjectorService;
injector: Injector;
ngZone: NgZone;
constructor(injector: Injector, ngZone: NgZone);
bootstrap(element: Element, modules?: string[], config?: angular.IAngularBootstrapConfig): void;
}