fix: split dynamic bits in platform-browser into platform-browser-dynamic
Previously these symbols were exposed via platform-browser-dynamic, then we merged then into platform-browser thinking that tools would know how to shake off the compiler and other dynamic bits not used with the offline compilation flow. This turned out to be wrong as both webpack and rollup don't have good enough tree-shaking capabilities to do this today. We think that in the future we'll be able to merge these two entry points into one, but we need to give tooling some time before we can do it. In the meantime the reintroduction of the -dynamic package point allows us to separate the compiler dependencies from the rest of the framework. This change undoes the previous breaking change that removed the platform-browser-dynamic package.
This commit is contained in:
@ -1,30 +1,50 @@
|
||||
import {DirectiveResolver, ViewResolver} from '@angular/compiler';
|
||||
import {MockDirectiveResolver, MockViewResolver, TestComponentBuilder, TestComponentRenderer} from '@angular/compiler/testing';
|
||||
import {LocationStrategy} from '@angular/common';
|
||||
import {MockLocationStrategy} from '@angular/common/testing';
|
||||
import {APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER} from '@angular/core';
|
||||
import {Log} from '@angular/core/testing';
|
||||
|
||||
import {BROWSER_APP_COMPILER_PROVIDERS, BROWSER_APP_PROVIDERS} from '../index';
|
||||
import {AnimationDriver, NoOpAnimationDriver} from '../core_private';
|
||||
import {BROWSER_APP_PROVIDERS} from '../src/browser';
|
||||
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||
import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
||||
|
||||
import {ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS, TEST_BROWSER_STATIC_PLATFORM_PROVIDERS} from './browser_static';
|
||||
import {DOMTestComponentRenderer} from './dom_test_component_renderer';
|
||||
import {BrowserDetection} from './browser_util';
|
||||
|
||||
|
||||
/**
|
||||
* Default platform providers for testing without a compiler.
|
||||
*/
|
||||
const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
||||
];
|
||||
|
||||
const ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
{provide: APP_ID, useValue: 'a'}, ELEMENT_PROBE_PROVIDERS, Log,
|
||||
{provide: NgZone, useFactory: createNgZone},
|
||||
{provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
{provide: AnimationDriver, useClass: NoOpAnimationDriver}
|
||||
];
|
||||
|
||||
|
||||
function initBrowserTests() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
BrowserDetection.setup();
|
||||
}
|
||||
|
||||
function createNgZone(): NgZone {
|
||||
return new NgZone({enableLongStackTrace: true});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default platform providers for testing.
|
||||
*/
|
||||
export const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[TEST_BROWSER_STATIC_PLATFORM_PROVIDERS];
|
||||
|
||||
|
||||
export const ADDITIONAL_TEST_BROWSER_PROVIDERS = [
|
||||
{provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
||||
{provide: ViewResolver, useClass: MockViewResolver},
|
||||
TestComponentBuilder,
|
||||
{provide: TestComponentRenderer, useClass: DOMTestComponentRenderer},
|
||||
];
|
||||
TEST_BROWSER_STATIC_PLATFORM_PROVIDERS;
|
||||
|
||||
/**
|
||||
* Default application providers for testing.
|
||||
* Default application providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS,
|
||||
ADDITIONAL_TEST_BROWSER_PROVIDERS
|
||||
];
|
||||
export const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[BROWSER_APP_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS];
|
||||
|
@ -1,42 +0,0 @@
|
||||
import {LocationStrategy} from '@angular/common';
|
||||
import {MockLocationStrategy} from '@angular/common/testing';
|
||||
import {APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER} from '@angular/core';
|
||||
import {Log} from '@angular/core/testing';
|
||||
|
||||
import {AnimationDriver, NoOpAnimationDriver} from '../core_private';
|
||||
import {BROWSER_APP_PROVIDERS} from '../src/browser';
|
||||
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||
import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
||||
|
||||
import {BrowserDetection} from './browser_util';
|
||||
|
||||
|
||||
/**
|
||||
* Default platform providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
||||
];
|
||||
|
||||
export const ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
{provide: APP_ID, useValue: 'a'}, ELEMENT_PROBE_PROVIDERS, Log,
|
||||
{provide: NgZone, useFactory: createNgZone},
|
||||
{provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
{provide: AnimationDriver, useClass: NoOpAnimationDriver}
|
||||
];
|
||||
|
||||
/**
|
||||
* Default application providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[BROWSER_APP_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS];
|
||||
|
||||
function initBrowserTests() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
BrowserDetection.setup();
|
||||
}
|
||||
|
||||
function createNgZone(): NgZone {
|
||||
return new NgZone({enableLongStackTrace: true});
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
import {TestComponentRenderer} from '@angular/compiler/testing';
|
||||
import {Inject, Injectable} from '@angular/core';
|
||||
|
||||
import {getDOM} from '../src/dom/dom_adapter';
|
||||
import {DOCUMENT} from '../src/dom/dom_tokens';
|
||||
|
||||
import {el} from './browser_util';
|
||||
|
||||
|
||||
/**
|
||||
* A DOM based implementation of the TestComponentRenderer.
|
||||
*/
|
||||
@Injectable()
|
||||
export class DOMTestComponentRenderer extends TestComponentRenderer {
|
||||
constructor(@Inject(DOCUMENT) private _doc: any /** TODO #9100 */) { super(); }
|
||||
|
||||
insertRootElement(rootElId: string) {
|
||||
let rootEl = el(`<div id="${rootElId}"></div>`);
|
||||
|
||||
// TODO(juliemr): can/should this be optional?
|
||||
let oldRoots = getDOM().querySelectorAll(this._doc, '[id^=root]');
|
||||
for (let i = 0; i < oldRoots.length; i++) {
|
||||
getDOM().remove(oldRoots[i]);
|
||||
}
|
||||
getDOM().appendChild(this._doc.body, rootEl);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user