refactor(ivy): obviate the Bazel component of the ivy_switch (#26550)
Originally, the ivy_switch mechanism used Bazel genrules to conditionally compile one TS file or another depending on whether ngc or ngtsc was the selected compiler. This was done because we wanted to avoid importing certain modules (and thus pulling them into the build) if Ivy was on or off. This mechanism had a major drawback: ivy_switch became a bottleneck in the import graph, as it both imports from many places in the codebase and is imported by many modules in the codebase. This frequently resulted in cyclic imports which caused issues both with TS and Closure compilation. It turns out ngcc needs both code paths in the bundle to perform the switch during its operation anyway, so import switching was later abandoned. This means that there's no real reason why the ivy_switch mechanism needed to operate at the Bazel level, and for the ivy_switch file to be a bottleneck. This commit removes the Bazel-level ivy_switch mechanism, and introduces an additional TypeScript transform in ngtsc (and the pass-through tsc compiler used for testing JIT) to perform the same operation that ngcc does, and flip the switch during ngtsc compilation. This allows the ivy_switch file to be removed, and the individual switches to be located directly next to their consumers in the codebase, greatly mitigating the circular import issues and making the mechanism much easier to use. As part of this commit, the tag for marking switched variables was changed from __PRE_NGCC__ to __PRE_R3__, since it's no longer just ngcc which flips these tags. Most variables were renamed from R3_* to SWITCH_* as well, since they're referenced mostly in render2 code. Test strategy: existing test coverage is more than sufficient - if this didn't work correctly it would break the hello world and todo apps. PR Close #26550
This commit is contained in:
parent
331989cea3
commit
d4cee514f6
|
@ -76,7 +76,7 @@ See also: [`//tools/bazel.rc`](https://github.com/angular/angular/blob/master/to
|
||||||
|
|
||||||
- `--config=debug`: build and launch in debug mode (see [debugging](#debugging) instructions below)
|
- `--config=debug`: build and launch in debug mode (see [debugging](#debugging) instructions below)
|
||||||
- `--test_arg=--node_options=--inspect=9228`: change the inspector port.
|
- `--test_arg=--node_options=--inspect=9228`: change the inspector port.
|
||||||
- `--define=compile=<option>` Controls if ivy or legacy mode is enabled. This is done by generating the [`src/ivy_switch.ts`](https://github.com/angular/angular/blob/master/packages/core/src/ivy_switch.ts) file from [`ivy_switch_legacy.ts`](https://github.com/angular/angular/blob/master/packages/core/src/ivy_switch_legacy.ts) (default), [`ivy_switch_jit.ts`](https://github.com/angular/angular/blob/master/packages/core/src/ivy_switch_jit.ts), or [`ivy_switch_local.ts`](https://github.com/angular/angular/blob/master/packages/core/src/ivy_switch_local.ts).
|
- `--define=compile=<option>` Controls if ivy or legacy mode is enabled. This switches which compiler is used (ngc, ngtsc, or a tsc pass-through mode).
|
||||||
- `legacy`: (default behavior) compile against View Engine, e.g. `--define=compile=legacy`
|
- `legacy`: (default behavior) compile against View Engine, e.g. `--define=compile=legacy`
|
||||||
- `jit`: Compile in ivy JIT mode, e.g. `--define=compile=jit`
|
- `jit`: Compile in ivy JIT mode, e.g. `--define=compile=jit`
|
||||||
- `local`: Compile in ivy AOT move, e.g. `--define=compile=local`
|
- `local`: Compile in ivy AOT move, e.g. `--define=compile=local`
|
||||||
|
|
|
@ -17,10 +17,10 @@ ivy-ngcc
|
||||||
ls node_modules/@angular/common | grep __modified_by_ngcc_for_esm2015
|
ls node_modules/@angular/common | grep __modified_by_ngcc_for_esm2015
|
||||||
if [[ $? != 0 ]]; then exit 1; fi
|
if [[ $? != 0 ]]; then exit 1; fi
|
||||||
|
|
||||||
# Did it replace the NGCC_PRE markers correctly?
|
# Did it replace the PRE_R3 markers correctly?
|
||||||
grep "= R3_COMPILE_COMPONENT__POST_NGCC__" node_modules/@angular/core/fesm2015/core.js
|
grep "= SWITCH_COMPILE_COMPONENT__POST_R3__" node_modules/@angular/core/fesm2015/core.js
|
||||||
if [[ $? != 0 ]]; then exit 1; fi
|
if [[ $? != 0 ]]; then exit 1; fi
|
||||||
grep "= R3_COMPILE_COMPONENT__POST_NGCC__" node_modules/@angular/core/fesm5/core.js
|
grep "= SWITCH_COMPILE_COMPONENT__POST_R3__" node_modules/@angular/core/fesm5/core.js
|
||||||
if [[ $? != 0 ]]; then exit 1; fi
|
if [[ $? != 0 ]]; then exit 1; fi
|
||||||
|
|
||||||
# Did it compile @angular/core/ApplicationModule correctly?
|
# Did it compile @angular/core/ApplicationModule correctly?
|
||||||
|
|
|
@ -29,6 +29,7 @@ ts_library(
|
||||||
"//packages/compiler-cli/src/ngtsc/diagnostics",
|
"//packages/compiler-cli/src/ngtsc/diagnostics",
|
||||||
"//packages/compiler-cli/src/ngtsc/factories",
|
"//packages/compiler-cli/src/ngtsc/factories",
|
||||||
"//packages/compiler-cli/src/ngtsc/metadata",
|
"//packages/compiler-cli/src/ngtsc/metadata",
|
||||||
|
"//packages/compiler-cli/src/ngtsc/switch",
|
||||||
"//packages/compiler-cli/src/ngtsc/transform",
|
"//packages/compiler-cli/src/ngtsc/transform",
|
||||||
"//packages/compiler-cli/src/ngtsc/typecheck",
|
"//packages/compiler-cli/src/ngtsc/typecheck",
|
||||||
],
|
],
|
||||||
|
|
|
@ -9,8 +9,8 @@ import * as ts from 'typescript';
|
||||||
import {ReflectionHost} from '../../../ngtsc/host';
|
import {ReflectionHost} from '../../../ngtsc/host';
|
||||||
import {DecoratedFile} from './decorated_file';
|
import {DecoratedFile} from './decorated_file';
|
||||||
|
|
||||||
export const PRE_NGCC_MARKER = '__PRE_NGCC__';
|
export const PRE_NGCC_MARKER = '__PRE_R3__';
|
||||||
export const POST_NGCC_MARKER = '__POST_NGCC__';
|
export const POST_NGCC_MARKER = '__POST_R3__';
|
||||||
|
|
||||||
export type SwitchableVariableDeclaration = ts.VariableDeclaration & {initializer: ts.Identifier};
|
export type SwitchableVariableDeclaration = ts.VariableDeclaration & {initializer: ts.Identifier};
|
||||||
export function isSwitchableVariableDeclaration(node: ts.Node):
|
export function isSwitchableVariableDeclaration(node: ts.Node):
|
||||||
|
|
|
@ -30,15 +30,15 @@ const TEST_PROGRAM = [
|
||||||
name: 'b.js',
|
name: 'b.js',
|
||||||
contents: `
|
contents: `
|
||||||
export const b = 42;
|
export const b = 42;
|
||||||
var factoryB = factory__PRE_NGCC__;
|
var factoryB = factory__PRE_R3__;
|
||||||
`
|
`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'c.js',
|
name: 'c.js',
|
||||||
contents: `
|
contents: `
|
||||||
export const c = 'So long, and thanks for all the fish!';
|
export const c = 'So long, and thanks for all the fish!';
|
||||||
var factoryC = factory__PRE_NGCC__;
|
var factoryC = factory__PRE_R3__;
|
||||||
var factoryD = factory__PRE_NGCC__;
|
var factoryD = factory__PRE_R3__;
|
||||||
`
|
`
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -62,14 +62,14 @@ describe('SwitchMarkerAnalyzer', () => {
|
||||||
expect(analysis.has(b)).toBe(true);
|
expect(analysis.has(b)).toBe(true);
|
||||||
expect(analysis.get(b) !.sourceFile).toBe(b);
|
expect(analysis.get(b) !.sourceFile).toBe(b);
|
||||||
expect(analysis.get(b) !.declarations.map(decl => decl.getText())).toEqual([
|
expect(analysis.get(b) !.declarations.map(decl => decl.getText())).toEqual([
|
||||||
'factoryB = factory__PRE_NGCC__'
|
'factoryB = factory__PRE_R3__'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(analysis.has(c)).toBe(true);
|
expect(analysis.has(c)).toBe(true);
|
||||||
expect(analysis.get(c) !.sourceFile).toBe(c);
|
expect(analysis.get(c) !.sourceFile).toBe(c);
|
||||||
expect(analysis.get(c) !.declarations.map(decl => decl.getText())).toEqual([
|
expect(analysis.get(c) !.declarations.map(decl => decl.getText())).toEqual([
|
||||||
'factoryC = factory__PRE_NGCC__',
|
'factoryC = factory__PRE_R3__',
|
||||||
'factoryD = factory__PRE_NGCC__',
|
'factoryD = factory__PRE_R3__',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,15 +35,15 @@ const CLASSES = [
|
||||||
const MARKER_FILE = {
|
const MARKER_FILE = {
|
||||||
name: '/marker.js',
|
name: '/marker.js',
|
||||||
contents: `
|
contents: `
|
||||||
let compileNgModuleFactory = compileNgModuleFactory__PRE_NGCC__;
|
let compileNgModuleFactory = compileNgModuleFactory__PRE_R3__;
|
||||||
|
|
||||||
function compileNgModuleFactory__PRE_NGCC__(injector, options, moduleType) {
|
function compileNgModuleFactory__PRE_R3__(injector, options, moduleType) {
|
||||||
const compilerFactory = injector.get(CompilerFactory);
|
const compilerFactory = injector.get(CompilerFactory);
|
||||||
const compiler = compilerFactory.createCompiler([options]);
|
const compiler = compilerFactory.createCompiler([options]);
|
||||||
return compiler.compileModuleAsync(moduleType);
|
return compiler.compileModuleAsync(moduleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
function compileNgModuleFactory__POST_NGCC__(injector, options, moduleType) {
|
function compileNgModuleFactory__POST_R3__(injector, options, moduleType) {
|
||||||
ngDevMode && assertNgModuleType(moduleType);
|
ngDevMode && assertNgModuleType(moduleType);
|
||||||
return Promise.resolve(new R3NgModuleFactory(moduleType));
|
return Promise.resolve(new R3NgModuleFactory(moduleType));
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||||
const file = program.getSourceFile(MARKER_FILE.name) !;
|
const file = program.getSourceFile(MARKER_FILE.name) !;
|
||||||
const declarations = host.getSwitchableDeclarations(file);
|
const declarations = host.getSwitchableDeclarations(file);
|
||||||
expect(declarations.map(d => [d.name.getText(), d.initializer !.getText()])).toEqual([
|
expect(declarations.map(d => [d.name.getText(), d.initializer !.getText()])).toEqual([
|
||||||
['compileNgModuleFactory', 'compileNgModuleFactory__PRE_NGCC__']
|
['compileNgModuleFactory', 'compileNgModuleFactory__PRE_R3__']
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -377,15 +377,15 @@ const FUNCTION_BODY_FILE = {
|
||||||
const MARKER_FILE = {
|
const MARKER_FILE = {
|
||||||
name: '/marker.js',
|
name: '/marker.js',
|
||||||
contents: `
|
contents: `
|
||||||
var compileNgModuleFactory = compileNgModuleFactory__PRE_NGCC__;
|
var compileNgModuleFactory = compileNgModuleFactory__PRE_R3__;
|
||||||
|
|
||||||
function compileNgModuleFactory__PRE_NGCC__(injector, options, moduleType) {
|
function compileNgModuleFactory__PRE_R3__(injector, options, moduleType) {
|
||||||
var compilerFactory = injector.get(CompilerFactory);
|
var compilerFactory = injector.get(CompilerFactory);
|
||||||
var compiler = compilerFactory.createCompiler([options]);
|
var compiler = compilerFactory.createCompiler([options]);
|
||||||
return compiler.compileModuleAsync(moduleType);
|
return compiler.compileModuleAsync(moduleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
function compileNgModuleFactory__POST_NGCC__(injector, options, moduleType) {
|
function compileNgModuleFactory__POST_R3__(injector, options, moduleType) {
|
||||||
ngDevMode && assertNgModuleType(moduleType);
|
ngDevMode && assertNgModuleType(moduleType);
|
||||||
return Promise.resolve(new R3NgModuleFactory(moduleType));
|
return Promise.resolve(new R3NgModuleFactory(moduleType));
|
||||||
}
|
}
|
||||||
|
@ -1179,7 +1179,7 @@ describe('Fesm2015ReflectionHost', () => {
|
||||||
const file = program.getSourceFile(MARKER_FILE.name) !;
|
const file = program.getSourceFile(MARKER_FILE.name) !;
|
||||||
const declarations = host.getSwitchableDeclarations(file);
|
const declarations = host.getSwitchableDeclarations(file);
|
||||||
expect(declarations.map(d => [d.name.getText(), d.initializer !.getText()])).toEqual([
|
expect(declarations.map(d => [d.name.getText(), d.initializer !.getText()])).toEqual([
|
||||||
['compileNgModuleFactory', 'compileNgModuleFactory__PRE_NGCC__']
|
['compileNgModuleFactory', 'compileNgModuleFactory__PRE_R3__']
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -48,16 +48,16 @@ export class C {}
|
||||||
C.decorators = [
|
C.decorators = [
|
||||||
{ type: Directive, args: [{ selector: '[c]' }] },
|
{ type: Directive, args: [{ selector: '[c]' }] },
|
||||||
];
|
];
|
||||||
let compileNgModuleFactory = compileNgModuleFactory__PRE_NGCC__;
|
let compileNgModuleFactory = compileNgModuleFactory__PRE_R3__;
|
||||||
let badlyFormattedVariable = __PRE_NGCC__badlyFormattedVariable;
|
let badlyFormattedVariable = __PRE_R3__badlyFormattedVariable;
|
||||||
|
|
||||||
function compileNgModuleFactory__PRE_NGCC__(injector, options, moduleType) {
|
function compileNgModuleFactory__PRE_R3__(injector, options, moduleType) {
|
||||||
const compilerFactory = injector.get(CompilerFactory);
|
const compilerFactory = injector.get(CompilerFactory);
|
||||||
const compiler = compilerFactory.createCompiler([options]);
|
const compiler = compilerFactory.createCompiler([options]);
|
||||||
return compiler.compileModuleAsync(moduleType);
|
return compiler.compileModuleAsync(moduleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
function compileNgModuleFactory__POST_NGCC__(injector, options, moduleType) {
|
function compileNgModuleFactory__POST_R3__(injector, options, moduleType) {
|
||||||
ngDevMode && assertNgModuleType(moduleType);
|
ngDevMode && assertNgModuleType(moduleType);
|
||||||
return Promise.resolve(new R3NgModuleFactory(moduleType));
|
return Promise.resolve(new R3NgModuleFactory(moduleType));
|
||||||
}
|
}
|
||||||
|
@ -146,17 +146,15 @@ export class A {}`);
|
||||||
renderer.rewriteSwitchableDeclarations(
|
renderer.rewriteSwitchableDeclarations(
|
||||||
output, file, switchMarkerAnalyses.get(sourceFile) !.declarations);
|
output, file, switchMarkerAnalyses.get(sourceFile) !.declarations);
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.not.toContain(`let compileNgModuleFactory = compileNgModuleFactory__PRE_NGCC__;`);
|
.not.toContain(`let compileNgModuleFactory = compileNgModuleFactory__PRE_R3__;`);
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.toContain(`let badlyFormattedVariable = __PRE_NGCC__badlyFormattedVariable;`);
|
.toContain(`let badlyFormattedVariable = __PRE_R3__badlyFormattedVariable;`);
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.toContain(`let compileNgModuleFactory = compileNgModuleFactory__POST_NGCC__;`);
|
.toContain(`let compileNgModuleFactory = compileNgModuleFactory__POST_R3__;`);
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.toContain(
|
.toContain(`function compileNgModuleFactory__PRE_R3__(injector, options, moduleType) {`);
|
||||||
`function compileNgModuleFactory__PRE_NGCC__(injector, options, moduleType) {`);
|
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.toContain(
|
.toContain(`function compileNgModuleFactory__POST_R3__(injector, options, moduleType) {`);
|
||||||
`function compileNgModuleFactory__POST_NGCC__(injector, options, moduleType) {`);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -55,15 +55,15 @@ var C = (function() {
|
||||||
return C;
|
return C;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
var compileNgModuleFactory = compileNgModuleFactory__PRE_NGCC__;
|
var compileNgModuleFactory = compileNgModuleFactory__PRE_R3__;
|
||||||
var badlyFormattedVariable = __PRE_NGCC__badlyFormattedVariable;
|
var badlyFormattedVariable = __PRE_R3__badlyFormattedVariable;
|
||||||
function compileNgModuleFactory__PRE_NGCC__(injector, options, moduleType) {
|
function compileNgModuleFactory__PRE_R3__(injector, options, moduleType) {
|
||||||
const compilerFactory = injector.get(CompilerFactory);
|
const compilerFactory = injector.get(CompilerFactory);
|
||||||
const compiler = compilerFactory.createCompiler([options]);
|
const compiler = compilerFactory.createCompiler([options]);
|
||||||
return compiler.compileModuleAsync(moduleType);
|
return compiler.compileModuleAsync(moduleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
function compileNgModuleFactory__POST_NGCC__(injector, options, moduleType) {
|
function compileNgModuleFactory__POST_R3__(injector, options, moduleType) {
|
||||||
ngDevMode && assertNgModuleType(moduleType);
|
ngDevMode && assertNgModuleType(moduleType);
|
||||||
return Promise.resolve(new R3NgModuleFactory(moduleType));
|
return Promise.resolve(new R3NgModuleFactory(moduleType));
|
||||||
}
|
}
|
||||||
|
@ -166,17 +166,15 @@ var A = (function() {`);
|
||||||
renderer.rewriteSwitchableDeclarations(
|
renderer.rewriteSwitchableDeclarations(
|
||||||
output, file, switchMarkerAnalyses.get(sourceFile) !.declarations);
|
output, file, switchMarkerAnalyses.get(sourceFile) !.declarations);
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.not.toContain(`var compileNgModuleFactory = compileNgModuleFactory__PRE_NGCC__;`);
|
.not.toContain(`var compileNgModuleFactory = compileNgModuleFactory__PRE_R3__;`);
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.toContain(`var badlyFormattedVariable = __PRE_NGCC__badlyFormattedVariable;`);
|
.toContain(`var badlyFormattedVariable = __PRE_R3__badlyFormattedVariable;`);
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.toContain(`var compileNgModuleFactory = compileNgModuleFactory__POST_NGCC__;`);
|
.toContain(`var compileNgModuleFactory = compileNgModuleFactory__POST_R3__;`);
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.toContain(
|
.toContain(`function compileNgModuleFactory__PRE_R3__(injector, options, moduleType) {`);
|
||||||
`function compileNgModuleFactory__PRE_NGCC__(injector, options, moduleType) {`);
|
|
||||||
expect(output.toString())
|
expect(output.toString())
|
||||||
.toContain(
|
.toContain(`function compileNgModuleFactory__POST_R3__(injector, options, moduleType) {`);
|
||||||
`function compileNgModuleFactory__POST_NGCC__(injector, options, moduleType) {`);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import {BaseDefDecoratorHandler} from './annotations/src/base_def';
|
||||||
import {FactoryGenerator, FactoryInfo, GeneratedFactoryHostWrapper, generatedFactoryTransform} from './factories';
|
import {FactoryGenerator, FactoryInfo, GeneratedFactoryHostWrapper, generatedFactoryTransform} from './factories';
|
||||||
import {TypeScriptReflectionHost} from './metadata';
|
import {TypeScriptReflectionHost} from './metadata';
|
||||||
import {FileResourceLoader, HostResourceLoader} from './resource_loader';
|
import {FileResourceLoader, HostResourceLoader} from './resource_loader';
|
||||||
|
import {ivySwitchTransform} from './switch';
|
||||||
import {IvyCompilation, ivyTransformFactory} from './transform';
|
import {IvyCompilation, ivyTransformFactory} from './transform';
|
||||||
import {TypeCheckContext, TypeCheckProgramHost} from './typecheck';
|
import {TypeCheckContext, TypeCheckProgramHost} from './typecheck';
|
||||||
|
|
||||||
|
@ -177,6 +178,9 @@ export class NgtscProgram implements api.Program {
|
||||||
if (this.factoryToSourceInfo !== null) {
|
if (this.factoryToSourceInfo !== null) {
|
||||||
transforms.push(generatedFactoryTransform(this.factoryToSourceInfo, this.coreImportsFrom));
|
transforms.push(generatedFactoryTransform(this.factoryToSourceInfo, this.coreImportsFrom));
|
||||||
}
|
}
|
||||||
|
if (this.isCore) {
|
||||||
|
transforms.push(ivySwitchTransform);
|
||||||
|
}
|
||||||
// Run the emit, including a custom transformer that will downlevel the Ivy decorators in code.
|
// Run the emit, including a custom transformer that will downlevel the Ivy decorators in code.
|
||||||
const emitResult = emitCallback({
|
const emitResult = emitCallback({
|
||||||
program: this.tsProgram,
|
program: this.tsProgram,
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
|
load("//tools:defaults.bzl", "ts_library")
|
||||||
|
|
||||||
|
ts_library(
|
||||||
|
name = "switch",
|
||||||
|
srcs = glob([
|
||||||
|
"index.ts",
|
||||||
|
"src/**/*.ts",
|
||||||
|
]),
|
||||||
|
module_name = "@angular/compiler-cli/src/ngtsc/switch",
|
||||||
|
deps = [
|
||||||
|
"//packages/compiler",
|
||||||
|
"//packages/compiler-cli/src/ngtsc/host",
|
||||||
|
"//packages/compiler-cli/src/ngtsc/metadata",
|
||||||
|
"//packages/compiler-cli/src/ngtsc/util",
|
||||||
|
],
|
||||||
|
)
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* Copyright Google Inc. All Rights Reserved.
|
* Copyright Google Inc. All Rights Reserved.
|
||||||
|
@ -7,4 +6,4 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './ivy_switch_on';
|
export {ivySwitchTransform} from './src/switch';
|
|
@ -0,0 +1,152 @@
|
||||||
|
/**
|
||||||
|
* @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 * as ts from 'typescript';
|
||||||
|
|
||||||
|
const IVY_SWITCH_PRE_SUFFIX = '__PRE_R3__';
|
||||||
|
const IVY_SWITCH_POST_SUFFIX = '__POST_R3__';
|
||||||
|
|
||||||
|
export function ivySwitchTransform(_: ts.TransformationContext): ts.Transformer<ts.SourceFile> {
|
||||||
|
return flipIvySwitchInFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
function flipIvySwitchInFile(sf: ts.SourceFile): ts.SourceFile {
|
||||||
|
// To replace the statements array, it must be copied. This only needs to happen if a statement
|
||||||
|
// must actually be replaced within the array, so the newStatements array is lazily initialized.
|
||||||
|
let newStatements: ts.Statement[]|undefined = undefined;
|
||||||
|
|
||||||
|
// Iterate over the statements in the file.
|
||||||
|
for (let i = 0; i < sf.statements.length; i++) {
|
||||||
|
const statement = sf.statements[i];
|
||||||
|
|
||||||
|
// Skip over everything that isn't a variable statement.
|
||||||
|
if (!ts.isVariableStatement(statement) || !hasIvySwitches(statement)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This statement needs to be replaced. Check if the newStatements array needs to be lazily
|
||||||
|
// initialized to a copy of the original statements.
|
||||||
|
if (newStatements === undefined) {
|
||||||
|
newStatements = [...sf.statements];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flip any switches in the VariableStatement. If there were any, a new statement will be
|
||||||
|
// returned; otherwise the old statement will be.
|
||||||
|
newStatements[i] = flipIvySwitchesInVariableStatement(statement, sf.statements);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only update the statements in the SourceFile if any have changed.
|
||||||
|
if (newStatements !== undefined) {
|
||||||
|
sf.statements = ts.createNodeArray(newStatements);
|
||||||
|
}
|
||||||
|
return sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look for the ts.Identifier of a ts.Declaration with this name.
|
||||||
|
*
|
||||||
|
* The real identifier is needed (rather than fabricating one) as TypeScript decides how to
|
||||||
|
* reference this identifier based on information stored against its node in the AST, which a
|
||||||
|
* synthetic node would not have. In particular, since the post-switch variable is often exported,
|
||||||
|
* TypeScript needs to know this so it can write `exports.VAR` instead of just `VAR` when emitting
|
||||||
|
* code.
|
||||||
|
*
|
||||||
|
* Only variable, function, and class declarations are currently searched.
|
||||||
|
*/
|
||||||
|
function findPostSwitchIdentifier(
|
||||||
|
statements: ReadonlyArray<ts.Statement>, name: string): ts.Identifier|null {
|
||||||
|
for (const stmt of statements) {
|
||||||
|
if (ts.isVariableStatement(stmt)) {
|
||||||
|
const decl = stmt.declarationList.declarations.find(
|
||||||
|
decl => ts.isIdentifier(decl.name) && decl.name.text === name);
|
||||||
|
if (decl !== undefined) {
|
||||||
|
return decl.name as ts.Identifier;
|
||||||
|
}
|
||||||
|
} else if (ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) {
|
||||||
|
if (stmt.name !== undefined && ts.isIdentifier(stmt.name) && stmt.name.text === name) {
|
||||||
|
return stmt.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flip any Ivy switches which are discovered in the given ts.VariableStatement.
|
||||||
|
*/
|
||||||
|
function flipIvySwitchesInVariableStatement(
|
||||||
|
stmt: ts.VariableStatement, statements: ReadonlyArray<ts.Statement>): ts.VariableStatement {
|
||||||
|
// Build a new list of variable declarations. Specific declarations that are initialized to a
|
||||||
|
// pre-switch identifier will be replaced with a declaration initialized to the post-switch
|
||||||
|
// identifier.
|
||||||
|
const newDeclarations = [...stmt.declarationList.declarations];
|
||||||
|
for (let i = 0; i < newDeclarations.length; i++) {
|
||||||
|
const decl = newDeclarations[i];
|
||||||
|
|
||||||
|
// Skip declarations that aren't initialized to an identifier.
|
||||||
|
if (decl.initializer === undefined || !ts.isIdentifier(decl.initializer)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip declarations that aren't Ivy switches.
|
||||||
|
if (!decl.initializer.text.endsWith(IVY_SWITCH_PRE_SUFFIX)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine the name of the post-switch variable.
|
||||||
|
const postSwitchName =
|
||||||
|
decl.initializer.text.replace(IVY_SWITCH_PRE_SUFFIX, IVY_SWITCH_POST_SUFFIX);
|
||||||
|
|
||||||
|
// Find the post-switch variable identifier. If one can't be found, it's an error. This is
|
||||||
|
// reported as a thrown error and not a diagnostic as transformers cannot output diagnostics.
|
||||||
|
let newIdentifier = findPostSwitchIdentifier(statements, postSwitchName);
|
||||||
|
if (newIdentifier === null) {
|
||||||
|
throw new Error(
|
||||||
|
`Unable to find identifier ${postSwitchName} in ${stmt.getSourceFile().fileName} for the Ivy switch.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the identifier with updateIdentifier(). This copies the internal information which
|
||||||
|
// allows TS to write a correct reference to the identifier.
|
||||||
|
newIdentifier = ts.updateIdentifier(newIdentifier);
|
||||||
|
|
||||||
|
newDeclarations[i] = ts.updateVariableDeclaration(
|
||||||
|
/* node */ decl,
|
||||||
|
/* name */ decl.name,
|
||||||
|
/* type */ decl.type,
|
||||||
|
/* initializer */ newIdentifier);
|
||||||
|
|
||||||
|
// Keeping parent pointers up to date is important for emit.
|
||||||
|
newIdentifier.parent = newDeclarations[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
const newDeclList = ts.updateVariableDeclarationList(
|
||||||
|
/* declarationList */ stmt.declarationList,
|
||||||
|
/* declarations */ newDeclarations);
|
||||||
|
|
||||||
|
const newStmt = ts.updateVariableStatement(
|
||||||
|
/* statement */ stmt,
|
||||||
|
/* modifiers */ stmt.modifiers,
|
||||||
|
/* declarationList */ newDeclList);
|
||||||
|
|
||||||
|
// Keeping parent pointers up to date is important for emit.
|
||||||
|
for (const decl of newDeclarations) {
|
||||||
|
decl.parent = newDeclList;
|
||||||
|
}
|
||||||
|
newDeclList.parent = newStmt;
|
||||||
|
newStmt.parent = stmt.parent;
|
||||||
|
return newStmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given VariableStatement has any Ivy switch variables.
|
||||||
|
*/
|
||||||
|
function hasIvySwitches(stmt: ts.VariableStatement) {
|
||||||
|
return stmt.declarationList.declarations.some(
|
||||||
|
decl => decl.initializer !== undefined && ts.isIdentifier(decl.initializer) &&
|
||||||
|
decl.initializer.text.endsWith(IVY_SWITCH_PRE_SUFFIX));
|
||||||
|
}
|
|
@ -10,11 +10,15 @@ import {GeneratedFile} from '@angular/compiler';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
|
import {ivySwitchTransform} from '../ngtsc/switch';
|
||||||
import * as api from '../transformers/api';
|
import * as api from '../transformers/api';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of the `Program` API which behaves like plain `tsc` and does not include any
|
* An implementation of the `Program` API which behaves similarly to plain `tsc`.
|
||||||
* Angular-specific behavior whatsoever.
|
*
|
||||||
|
* The only Angular specific behavior included in this `Program` is the operation of the Ivy
|
||||||
|
* switch to turn on render3 behavior.
|
||||||
*
|
*
|
||||||
* This allows `ngc` to behave like `tsc` in cases where JIT code needs to be tested.
|
* This allows `ngc` to behave like `tsc` in cases where JIT code needs to be tested.
|
||||||
*/
|
*/
|
||||||
|
@ -95,6 +99,7 @@ export class TscPassThroughProgram implements api.Program {
|
||||||
host: this.host,
|
host: this.host,
|
||||||
options: this.options,
|
options: this.options,
|
||||||
emitOnlyDtsFiles: false,
|
emitOnlyDtsFiles: false,
|
||||||
|
customTransformers: {before: [ivySwitchTransform]},
|
||||||
});
|
});
|
||||||
return emitResult;
|
return emitResult;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,7 @@ ng_module(
|
||||||
"*.ts",
|
"*.ts",
|
||||||
"src/**/*.ts",
|
"src/**/*.ts",
|
||||||
],
|
],
|
||||||
exclude = [
|
),
|
||||||
"src/ivy_switch/compiler/index.ts",
|
|
||||||
"src/ivy_switch/runtime/index.ts",
|
|
||||||
],
|
|
||||||
) + [
|
|
||||||
":ivy_switch_compiler",
|
|
||||||
":ivy_switch_runtime",
|
|
||||||
],
|
|
||||||
module_name = "@angular/core",
|
module_name = "@angular/core",
|
||||||
deps = [
|
deps = [
|
||||||
"//packages:types",
|
"//packages:types",
|
||||||
|
@ -43,30 +36,3 @@ ng_package(
|
||||||
"//packages/core/testing",
|
"//packages/core/testing",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
## Controls if Ivy is enabled. (Temporary target until we permanently switch over to Ivy)
|
|
||||||
##
|
|
||||||
## This file generates the `src/ivy_switch/compiler/index.ts` and `src/ivy_switch/runtime/index.ts` files which
|
|
||||||
## reexport symbols for `ViewEngine` or `Ivy.`
|
|
||||||
## - append `--define=compile=legacy` (default) to `bazel` command to reexport `./legacy` from each folder
|
|
||||||
## in the 'ivy_switch' directory and use `ViewEngine`
|
|
||||||
## - append `--define=compile=jit` to `bazel` command to rexport `./jit` from each folder in the `ivy_switch`
|
|
||||||
## directory and use `Ivy`
|
|
||||||
## - append `--define=compile=local` to `bazel` command to rexport `./ivy_switch/compiler/jit` and use `Ivy`
|
|
||||||
## in the local analysis mode. (run as part of `ngtsc`)
|
|
||||||
##
|
|
||||||
## NOTE: `--define=compile=jit` works with any `bazel` command or target across the repo.
|
|
||||||
##
|
|
||||||
## See: `//tools/bazel.rc` where `--define=ivy=false` is defined as default.
|
|
||||||
## See: `./src/ivy_switch/compiler/index.ts` for more details.
|
|
||||||
genrule(
|
|
||||||
name = "ivy_switch_compiler",
|
|
||||||
outs = ["src/ivy_switch/compiler/index.ts"],
|
|
||||||
cmd = "echo export '*' from \"'./$(compile)';\" > $@",
|
|
||||||
)
|
|
||||||
|
|
||||||
genrule(
|
|
||||||
name = "ivy_switch_runtime",
|
|
||||||
outs = ["src/ivy_switch/runtime/index.ts"],
|
|
||||||
cmd = "echo export '*' from \"'./$(compile)';\" > $@",
|
|
||||||
)
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ let _platform: PlatformRef;
|
||||||
|
|
||||||
let compileNgModuleFactory:
|
let compileNgModuleFactory:
|
||||||
<M>(injector: Injector, options: CompilerOptions, moduleType: Type<M>) =>
|
<M>(injector: Injector, options: CompilerOptions, moduleType: Type<M>) =>
|
||||||
Promise<NgModuleFactory<M>> = compileNgModuleFactory__PRE_NGCC__;
|
Promise<NgModuleFactory<M>> = compileNgModuleFactory__PRE_R3__;
|
||||||
|
|
||||||
function compileNgModuleFactory__PRE_NGCC__<M>(
|
function compileNgModuleFactory__PRE_R3__<M>(
|
||||||
injector: Injector, options: CompilerOptions,
|
injector: Injector, options: CompilerOptions,
|
||||||
moduleType: Type<M>): Promise<NgModuleFactory<M>> {
|
moduleType: Type<M>): Promise<NgModuleFactory<M>> {
|
||||||
const compilerFactory: CompilerFactory = injector.get(CompilerFactory);
|
const compilerFactory: CompilerFactory = injector.get(CompilerFactory);
|
||||||
|
@ -43,7 +43,7 @@ function compileNgModuleFactory__PRE_NGCC__<M>(
|
||||||
return compiler.compileModuleAsync(moduleType);
|
return compiler.compileModuleAsync(moduleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compileNgModuleFactory__POST_NGCC__<M>(
|
export function compileNgModuleFactory__POST_R3__<M>(
|
||||||
injector: Injector, options: CompilerOptions,
|
injector: Injector, options: CompilerOptions,
|
||||||
moduleType: Type<M>): Promise<NgModuleFactory<M>> {
|
moduleType: Type<M>): Promise<NgModuleFactory<M>> {
|
||||||
ngDevMode && assertNgModuleType(moduleType);
|
ngDevMode && assertNgModuleType(moduleType);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {R3_CHANGE_DETECTOR_REF_FACTORY} from '../ivy_switch/runtime/index';
|
import {injectChangeDetectorRef as render3InjectChangeDetectorRef} from '../render3/view_engine_compatibility';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Angular Views, provides change detection functionality.
|
* Base class for Angular Views, provides change detection functionality.
|
||||||
|
@ -107,5 +107,12 @@ export abstract class ChangeDetectorRef {
|
||||||
abstract reattach(): void;
|
abstract reattach(): void;
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
static __NG_ELEMENT_ID__: () => ChangeDetectorRef = () => R3_CHANGE_DETECTOR_REF_FACTORY();
|
static __NG_ELEMENT_ID__: () => ChangeDetectorRef = () => SWITCH_CHANGE_DETECTOR_REF_FACTORY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const SWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__ = render3InjectChangeDetectorRef;
|
||||||
|
const SWITCH_CHANGE_DETECTOR_REF_FACTORY__PRE_R3__ = (...args: any[]): any => {};
|
||||||
|
const SWITCH_CHANGE_DETECTOR_REF_FACTORY: typeof render3InjectChangeDetectorRef =
|
||||||
|
SWITCH_CHANGE_DETECTOR_REF_FACTORY__PRE_R3__;
|
||||||
|
|
|
@ -16,7 +16,7 @@ export {Console as ɵConsole} from './console';
|
||||||
export {InjectableDef as ɵInjectableDef, InjectorDef as ɵInjectorDef, getInjectableDef as ɵgetInjectableDef} from './di/defs';
|
export {InjectableDef as ɵInjectableDef, InjectorDef as ɵInjectorDef, getInjectableDef as ɵgetInjectableDef} from './di/defs';
|
||||||
export {inject as ɵinject, setCurrentInjector as ɵsetCurrentInjector} from './di/injector';
|
export {inject as ɵinject, setCurrentInjector as ɵsetCurrentInjector} from './di/injector';
|
||||||
export {APP_ROOT as ɵAPP_ROOT} from './di/scope';
|
export {APP_ROOT as ɵAPP_ROOT} from './di/scope';
|
||||||
export {ivyEnabled as ɵivyEnabled} from './ivy_switch/compiler/index';
|
export {ivyEnabled as ɵivyEnabled} from './ivy_switch';
|
||||||
export {ComponentFactory as ɵComponentFactory} from './linker/component_factory';
|
export {ComponentFactory as ɵComponentFactory} from './linker/component_factory';
|
||||||
export {CodegenComponentFactoryResolver as ɵCodegenComponentFactoryResolver} from './linker/component_factory_resolver';
|
export {CodegenComponentFactoryResolver as ɵCodegenComponentFactoryResolver} from './linker/component_factory_resolver';
|
||||||
export {resolveComponentResources as ɵresolveComponentResources} from './metadata/resource_loading';
|
export {resolveComponentResources as ɵresolveComponentResources} from './metadata/resource_loading';
|
||||||
|
|
|
@ -129,12 +129,17 @@ export { Render3DebugRendererFactory2 as ɵRender3DebugRendererFactory2 } from
|
||||||
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
R3_COMPILE_NGMODULE_DEFS as ɵcompileNgModuleDefs,
|
compileComponent as ɵcompileComponent,
|
||||||
R3_PATCH_COMPONENT_DEF_WTIH_SCOPE as ɵpatchComponentDefWithScope,
|
compileDirective as ɵcompileDirective,
|
||||||
R3_COMPILE_COMPONENT as ɵcompileComponent,
|
} from './render3/jit/directive';
|
||||||
R3_COMPILE_DIRECTIVE as ɵcompileDirective,
|
export {
|
||||||
R3_COMPILE_PIPE as ɵcompilePipe,
|
compileNgModule as ɵcompileNgModule,
|
||||||
} from './ivy_switch/compiler/ivy_switch_on';
|
compileNgModuleDefs as ɵcompileNgModuleDefs,
|
||||||
|
patchComponentDefWithScope as ɵpatchComponentDefWithScope,
|
||||||
|
} from './render3/jit/module';
|
||||||
|
export {
|
||||||
|
compilePipe as ɵcompilePipe,
|
||||||
|
} from './render3/jit/pipe';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
NgModuleDef as ɵNgModuleDef,
|
NgModuleDef as ɵNgModuleDef,
|
||||||
|
@ -186,24 +191,37 @@ export {
|
||||||
//
|
//
|
||||||
// no code actually imports these symbols from the @angular/core entry point
|
// no code actually imports these symbols from the @angular/core entry point
|
||||||
export {
|
export {
|
||||||
compileNgModuleFactory__POST_NGCC__ as ɵcompileNgModuleFactory__POST_NGCC__
|
compileNgModuleFactory__POST_R3__ as ɵcompileNgModuleFactory__POST_R3__
|
||||||
} from './application_ref';
|
} from './application_ref';
|
||||||
export {
|
export {
|
||||||
R3_COMPILE_COMPONENT__POST_NGCC__ as ɵR3_COMPILE_COMPONENT__POST_NGCC__,
|
SWITCH_COMPILE_COMPONENT__POST_R3__ as ɵSWITCH_COMPILE_COMPONENT__POST_R3__,
|
||||||
R3_COMPILE_DIRECTIVE__POST_NGCC__ as ɵR3_COMPILE_DIRECTIVE__POST_NGCC__,
|
SWITCH_COMPILE_DIRECTIVE__POST_R3__ as ɵSWITCH_COMPILE_DIRECTIVE__POST_R3__,
|
||||||
R3_COMPILE_INJECTABLE__POST_NGCC__ as ɵR3_COMPILE_INJECTABLE__POST_NGCC__,
|
SWITCH_COMPILE_PIPE__POST_R3__ as ɵSWITCH_COMPILE_PIPE__POST_R3__,
|
||||||
R3_COMPILE_NGMODULE__POST_NGCC__ as ɵR3_COMPILE_NGMODULE__POST_NGCC__,
|
} from './metadata/directives';
|
||||||
R3_COMPILE_PIPE__POST_NGCC__ as ɵR3_COMPILE_PIPE__POST_NGCC__,
|
|
||||||
ivyEnable__POST_NGCC__ as ɵivyEnable__POST_NGCC__,
|
|
||||||
} from './ivy_switch/compiler/legacy';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
R3_ELEMENT_REF_FACTORY__POST_NGCC__ as ɵR3_ELEMENT_REF_FACTORY__POST_NGCC__,
|
SWITCH_COMPILE_NGMODULE__POST_R3__ as ɵSWITCH_COMPILE_NGMODULE__POST_R3__,
|
||||||
R3_TEMPLATE_REF_FACTORY__POST_NGCC__ as ɵR3_TEMPLATE_REF_FACTORY__POST_NGCC__,
|
} from './metadata/ng_module';
|
||||||
R3_CHANGE_DETECTOR_REF_FACTORY__POST_NGCC__ as ɵR3_CHANGE_DETECTOR_REF_FACTORY__POST_NGCC__,
|
export {
|
||||||
R3_VIEW_CONTAINER_REF_FACTORY__POST_NGCC__ as ɵR3_VIEW_CONTAINER_REF_FACTORY__POST_NGCC__,
|
SWITCH_COMPILE_INJECTABLE__POST_R3__ as ɵSWITCH_COMPILE_INJECTABLE__POST_R3__,
|
||||||
R3_RENDERER2_FACTORY__POST_NGCC__ as ɵR3_RENDERER2_FACTORY__POST_NGCC__,
|
} from './di/injectable';
|
||||||
} from './ivy_switch/runtime/legacy';
|
export {
|
||||||
|
SWITCH_IVY_ENABLED__POST_R3__ as ɵSWITCH_IVY_ENABLED__POST_R3__,
|
||||||
|
} from './ivy_switch';
|
||||||
|
export {
|
||||||
|
SWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__ as ɵSWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__,
|
||||||
|
} from './change_detection/change_detector_ref';
|
||||||
|
export {
|
||||||
|
SWITCH_ELEMENT_REF_FACTORY__POST_R3__ as ɵSWITCH_ELEMENT_REF_FACTORY__POST_R3__,
|
||||||
|
} from './linker/element_ref';
|
||||||
|
export {
|
||||||
|
SWITCH_TEMPLATE_REF_FACTORY__POST_R3__ as ɵSWITCH_TEMPLATE_REF_FACTORY__POST_R3__,
|
||||||
|
} from './linker/template_ref';
|
||||||
|
export {
|
||||||
|
SWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__ as ɵSWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__,
|
||||||
|
} from './linker/view_container_ref';
|
||||||
|
export {
|
||||||
|
SWITCH_RENDERER2_FACTORY__POST_R3__ as ɵSWITCH_RENDERER2_FACTORY__POST_R3__,
|
||||||
|
} from './render/api';
|
||||||
|
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {R3_COMPILE_INJECTABLE} from '../ivy_switch/compiler/index';
|
import {compileInjectable as render3CompileInjectable} from '../render3/jit/injectable';
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
import {makeDecorator} from '../util/decorators';
|
import {makeDecorator} from '../util/decorators';
|
||||||
|
|
||||||
import {InjectableDef, InjectableType} from './defs';
|
import {InjectableDef, InjectableType, defineInjectable, getInjectableDef} from './defs';
|
||||||
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueProvider, ValueSansProvider} from './provider';
|
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueSansProvider} from './provider';
|
||||||
|
import {convertInjectableProviderToFactory} from './util';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injectable providers used in `@Injectable` decorator.
|
* Injectable providers used in `@Injectable` decorator.
|
||||||
|
@ -61,7 +63,7 @@ export interface Injectable { providedIn?: Type<any>|'root'|null; }
|
||||||
*/
|
*/
|
||||||
export const Injectable: InjectableDecorator = makeDecorator(
|
export const Injectable: InjectableDecorator = makeDecorator(
|
||||||
'Injectable', undefined, undefined, undefined,
|
'Injectable', undefined, undefined, undefined,
|
||||||
(type: Type<any>, meta: Injectable) => R3_COMPILE_INJECTABLE(type, meta));
|
(type: Type<any>, meta: Injectable) => SWITCH_COMPILE_INJECTABLE(type as any, meta));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type representing injectable service.
|
* Type representing injectable service.
|
||||||
|
@ -69,3 +71,22 @@ export const Injectable: InjectableDecorator = makeDecorator(
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export interface InjectableType<T> extends Type<T> { ngInjectableDef: InjectableDef<T>; }
|
export interface InjectableType<T> extends Type<T> { ngInjectableDef: InjectableDef<T>; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supports @Injectable() in JIT mode for Render2.
|
||||||
|
*/
|
||||||
|
function render2CompileInjectable(
|
||||||
|
injectableType: InjectableType<any>,
|
||||||
|
options: {providedIn?: Type<any>| 'root' | null} & InjectableProvider): void {
|
||||||
|
if (options && options.providedIn !== undefined && !getInjectableDef(injectableType)) {
|
||||||
|
injectableType.ngInjectableDef = defineInjectable({
|
||||||
|
providedIn: options.providedIn,
|
||||||
|
factory: convertInjectableProviderToFactory(injectableType, options),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SWITCH_COMPILE_INJECTABLE__POST_R3__ = render3CompileInjectable;
|
||||||
|
const SWITCH_COMPILE_INJECTABLE__PRE_R3__ = render2CompileInjectable;
|
||||||
|
const SWITCH_COMPILE_INJECTABLE: typeof render3CompileInjectable =
|
||||||
|
SWITCH_COMPILE_INJECTABLE__PRE_R3__;
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* @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 {ReflectionCapabilities} from '../reflection/reflection_capabilities';
|
||||||
|
import {Type} from '../type';
|
||||||
|
import {getClosureSafeProperty} from '../util/property';
|
||||||
|
|
||||||
|
import {inject, injectArgs} from './injector';
|
||||||
|
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueProvider, ValueSansProvider} from './provider';
|
||||||
|
|
||||||
|
const USE_VALUE =
|
||||||
|
getClosureSafeProperty<ValueProvider>({provide: String, useValue: getClosureSafeProperty});
|
||||||
|
const EMPTY_ARRAY: any[] = [];
|
||||||
|
|
||||||
|
export function convertInjectableProviderToFactory(
|
||||||
|
type: Type<any>, provider?: ValueSansProvider | ExistingSansProvider | StaticClassSansProvider |
|
||||||
|
ConstructorSansProvider | FactorySansProvider | ClassSansProvider): () => any {
|
||||||
|
if (!provider) {
|
||||||
|
const reflectionCapabilities = new ReflectionCapabilities();
|
||||||
|
const deps = reflectionCapabilities.parameters(type);
|
||||||
|
// TODO - convert to flags.
|
||||||
|
return () => new type(...injectArgs(deps as any[]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (USE_VALUE in provider) {
|
||||||
|
const valueProvider = (provider as ValueSansProvider);
|
||||||
|
return () => valueProvider.useValue;
|
||||||
|
} else if ((provider as ExistingSansProvider).useExisting) {
|
||||||
|
const existingProvider = (provider as ExistingSansProvider);
|
||||||
|
return () => inject(existingProvider.useExisting);
|
||||||
|
} else if ((provider as FactorySansProvider).useFactory) {
|
||||||
|
const factoryProvider = (provider as FactorySansProvider);
|
||||||
|
return () => factoryProvider.useFactory(...injectArgs(factoryProvider.deps || EMPTY_ARRAY));
|
||||||
|
} else if ((provider as StaticClassSansProvider | ClassSansProvider).useClass) {
|
||||||
|
const classProvider = (provider as StaticClassSansProvider | ClassSansProvider);
|
||||||
|
let deps = (provider as StaticClassSansProvider).deps;
|
||||||
|
if (!deps) {
|
||||||
|
const reflectionCapabilities = new ReflectionCapabilities();
|
||||||
|
deps = reflectionCapabilities.parameters(type);
|
||||||
|
}
|
||||||
|
return () => new classProvider.useClass(...injectArgs(deps));
|
||||||
|
} else {
|
||||||
|
let deps = (provider as ConstructorSansProvider).deps;
|
||||||
|
if (!deps) {
|
||||||
|
const reflectionCapabilities = new ReflectionCapabilities();
|
||||||
|
deps = reflectionCapabilities.parameters(type);
|
||||||
|
}
|
||||||
|
return () => new type(...injectArgs(deps !));
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,4 +6,6 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './ivy_switch_on';
|
export const SWITCH_IVY_ENABLED__POST_R3__ = true;
|
||||||
|
const SWITCH_IVY_ENABLED__PRE_R3__ = false;
|
||||||
|
export const ivyEnabled = SWITCH_IVY_ENABLED__PRE_R3__;
|
|
@ -1,17 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This file is used to control if the default rendering pipeline should be `ViewEngine` or `Ivy`.
|
|
||||||
*
|
|
||||||
* For more information on how to run and debug tests with either Ivy or View Engine (legacy),
|
|
||||||
* please see [BAZEL.md](./docs/BAZEL.md).
|
|
||||||
*/
|
|
||||||
export * from './legacy';
|
|
||||||
|
|
||||||
// TODO(alxhub): debug why metadata doesn't properly propagate through this file.
|
|
|
@ -1,21 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {compileComponent, compileDirective} from '../../render3/jit/directive';
|
|
||||||
import {compileInjectable} from '../../render3/jit/injectable';
|
|
||||||
import {compileNgModule, compileNgModuleDefs, patchComponentDefWithScope} from '../../render3/jit/module';
|
|
||||||
import {compilePipe} from '../../render3/jit/pipe';
|
|
||||||
|
|
||||||
export const ivyEnabled = true;
|
|
||||||
export const R3_COMPILE_COMPONENT = compileComponent;
|
|
||||||
export const R3_COMPILE_DIRECTIVE = compileDirective;
|
|
||||||
export const R3_COMPILE_INJECTABLE = compileInjectable;
|
|
||||||
export const R3_COMPILE_NGMODULE = compileNgModule;
|
|
||||||
export const R3_COMPILE_PIPE = compilePipe;
|
|
||||||
export const R3_COMPILE_NGMODULE_DEFS = compileNgModuleDefs;
|
|
||||||
export const R3_PATCH_COMPONENT_DEF_WTIH_SCOPE = patchComponentDefWithScope;
|
|
|
@ -1,126 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {InjectableType, InjectorType, defineInjectable, defineInjector, getInjectableDef} from '../../di/defs';
|
|
||||||
import {InjectableProvider} from '../../di/injectable';
|
|
||||||
import {inject, injectArgs} from '../../di/injector';
|
|
||||||
import {ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueProvider, ValueSansProvider} from '../../di/provider';
|
|
||||||
import {NgModule} from '../../metadata';
|
|
||||||
import {ReflectionCapabilities} from '../../reflection/reflection_capabilities';
|
|
||||||
import {Type} from '../../type';
|
|
||||||
import {getClosureSafeProperty} from '../../util/property';
|
|
||||||
|
|
||||||
import * as ivyOn from './ivy_switch_on';
|
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
|
|
||||||
export interface DirectiveCompiler { (type: any, meta: any): void; }
|
|
||||||
|
|
||||||
export const R3_COMPILE_COMPONENT__POST_NGCC__: DirectiveCompiler = ivyOn.R3_COMPILE_COMPONENT;
|
|
||||||
export const R3_COMPILE_DIRECTIVE__POST_NGCC__: DirectiveCompiler = ivyOn.R3_COMPILE_DIRECTIVE;
|
|
||||||
export const R3_COMPILE_INJECTABLE__POST_NGCC__: DirectiveCompiler = ivyOn.R3_COMPILE_INJECTABLE;
|
|
||||||
export const R3_COMPILE_NGMODULE__POST_NGCC__: DirectiveCompiler = ivyOn.R3_COMPILE_NGMODULE;
|
|
||||||
export const R3_COMPILE_PIPE__POST_NGCC__: DirectiveCompiler = ivyOn.R3_COMPILE_PIPE;
|
|
||||||
export const R3_COMPILE_NGMODULE_DEFS__POST_NGCC__: DirectiveCompiler =
|
|
||||||
ivyOn.R3_COMPILE_NGMODULE_DEFS;
|
|
||||||
export const R3_PATCH_COMPONENT_DEF_WTIH_SCOPE__POST_NGCC__: DirectiveCompiler =
|
|
||||||
ivyOn.R3_PATCH_COMPONENT_DEF_WTIH_SCOPE;
|
|
||||||
|
|
||||||
export const ivyEnable__POST_NGCC__: boolean = ivyOn.ivyEnabled;
|
|
||||||
|
|
||||||
const R3_COMPILE_COMPONENT__PRE_NGCC__: DirectiveCompiler = noop;
|
|
||||||
const R3_COMPILE_DIRECTIVE__PRE_NGCC__: DirectiveCompiler = noop;
|
|
||||||
const R3_COMPILE_INJECTABLE__PRE_NGCC__: DirectiveCompiler = preR3InjectableCompile;
|
|
||||||
const R3_COMPILE_NGMODULE__PRE_NGCC__: DirectiveCompiler = preR3NgModuleCompile;
|
|
||||||
const R3_COMPILE_PIPE__PRE_NGCC__: DirectiveCompiler = noop;
|
|
||||||
const R3_COMPILE_NGMODULE_DEFS__PRE_NGCC__: DirectiveCompiler = noop;
|
|
||||||
const R3_PATCH_COMPONENT_DEF_WTIH_SCOPE__PRE_NGCC__: DirectiveCompiler = noop;
|
|
||||||
|
|
||||||
const ivyEnable__PRE_NGCC__ = false;
|
|
||||||
|
|
||||||
export const ivyEnabled = ivyEnable__PRE_NGCC__;
|
|
||||||
export let R3_COMPILE_COMPONENT: DirectiveCompiler = R3_COMPILE_COMPONENT__PRE_NGCC__;
|
|
||||||
export let R3_COMPILE_DIRECTIVE: DirectiveCompiler = R3_COMPILE_DIRECTIVE__PRE_NGCC__;
|
|
||||||
export let R3_COMPILE_INJECTABLE: DirectiveCompiler = R3_COMPILE_INJECTABLE__PRE_NGCC__;
|
|
||||||
export let R3_COMPILE_NGMODULE: DirectiveCompiler = R3_COMPILE_NGMODULE__PRE_NGCC__;
|
|
||||||
export let R3_COMPILE_PIPE: DirectiveCompiler = R3_COMPILE_PIPE__PRE_NGCC__;
|
|
||||||
export let R3_COMPILE_NGMODULE_DEFS: DirectiveCompiler = R3_COMPILE_NGMODULE_DEFS__PRE_NGCC__;
|
|
||||||
export let R3_PATCH_COMPONENT_DEF_WTIH_SCOPE: DirectiveCompiler =
|
|
||||||
R3_PATCH_COMPONENT_DEF_WTIH_SCOPE__PRE_NGCC__;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
// Glue code which should be removed after Ivy is default //
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function preR3NgModuleCompile(moduleType: InjectorType<any>, metadata: NgModule): void {
|
|
||||||
let imports = (metadata && metadata.imports) || [];
|
|
||||||
if (metadata && metadata.exports) {
|
|
||||||
imports = [...imports, metadata.exports];
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleType.ngInjectorDef = defineInjector({
|
|
||||||
factory: convertInjectableProviderToFactory(moduleType, {useClass: moduleType}),
|
|
||||||
providers: metadata && metadata.providers,
|
|
||||||
imports: imports,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const USE_VALUE =
|
|
||||||
getClosureSafeProperty<ValueProvider>({provide: String, useValue: getClosureSafeProperty});
|
|
||||||
const EMPTY_ARRAY: any[] = [];
|
|
||||||
|
|
||||||
function convertInjectableProviderToFactory(type: Type<any>, provider?: InjectableProvider): () =>
|
|
||||||
any {
|
|
||||||
if (!provider) {
|
|
||||||
const reflectionCapabilities = new ReflectionCapabilities();
|
|
||||||
const deps = reflectionCapabilities.parameters(type);
|
|
||||||
// TODO - convert to flags.
|
|
||||||
return () => new type(...injectArgs(deps as any[]));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (USE_VALUE in provider) {
|
|
||||||
const valueProvider = (provider as ValueSansProvider);
|
|
||||||
return () => valueProvider.useValue;
|
|
||||||
} else if ((provider as ExistingSansProvider).useExisting) {
|
|
||||||
const existingProvider = (provider as ExistingSansProvider);
|
|
||||||
return () => inject(existingProvider.useExisting);
|
|
||||||
} else if ((provider as FactorySansProvider).useFactory) {
|
|
||||||
const factoryProvider = (provider as FactorySansProvider);
|
|
||||||
return () => factoryProvider.useFactory(...injectArgs(factoryProvider.deps || EMPTY_ARRAY));
|
|
||||||
} else if ((provider as StaticClassSansProvider | ClassSansProvider).useClass) {
|
|
||||||
const classProvider = (provider as StaticClassSansProvider | ClassSansProvider);
|
|
||||||
let deps = (provider as StaticClassSansProvider).deps;
|
|
||||||
if (!deps) {
|
|
||||||
const reflectionCapabilities = new ReflectionCapabilities();
|
|
||||||
deps = reflectionCapabilities.parameters(type);
|
|
||||||
}
|
|
||||||
return () => new classProvider.useClass(...injectArgs(deps));
|
|
||||||
} else {
|
|
||||||
let deps = (provider as ConstructorSansProvider).deps;
|
|
||||||
if (!deps) {
|
|
||||||
const reflectionCapabilities = new ReflectionCapabilities();
|
|
||||||
deps = reflectionCapabilities.parameters(type);
|
|
||||||
}
|
|
||||||
return () => new type(...injectArgs(deps !));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Supports @Injectable() in JIT mode for Render2.
|
|
||||||
*/
|
|
||||||
function preR3InjectableCompile(
|
|
||||||
injectableType: InjectableType<any>,
|
|
||||||
options: {providedIn?: Type<any>| 'root' | null} & InjectableProvider): void {
|
|
||||||
if (options && options.providedIn !== undefined && !getInjectableDef(injectableType)) {
|
|
||||||
injectableType.ngInjectableDef = defineInjectable({
|
|
||||||
providedIn: options.providedIn,
|
|
||||||
factory: convertInjectableProviderToFactory(injectableType, options),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This file is used to control if the default rendering pipeline should be `ViewEngine` or `Ivy`.
|
|
||||||
*
|
|
||||||
* For more information on how to run and debug tests with either Ivy or View Engine (legacy),
|
|
||||||
* please see [BAZEL.md](./docs/BAZEL.md).
|
|
||||||
*/
|
|
||||||
export * from './legacy';
|
|
|
@ -1,15 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {injectChangeDetectorRef, injectElementRef, injectRenderer2, injectTemplateRef, injectViewContainerRef} from '../../render3/view_engine_compatibility';
|
|
||||||
|
|
||||||
export const R3_ELEMENT_REF_FACTORY = injectElementRef;
|
|
||||||
export const R3_TEMPLATE_REF_FACTORY = injectTemplateRef;
|
|
||||||
export const R3_CHANGE_DETECTOR_REF_FACTORY = injectChangeDetectorRef;
|
|
||||||
export const R3_VIEW_CONTAINER_REF_FACTORY = injectViewContainerRef;
|
|
||||||
export const R3_RENDERER2_FACTORY = injectRenderer2;
|
|
|
@ -1,34 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
import * as ivyOn from './ivy_switch_on';
|
|
||||||
|
|
||||||
function noopFactory(...tokens: any[]): any {}
|
|
||||||
|
|
||||||
type FactoryFunction<T = any> = (...tokens: any[]) => T;
|
|
||||||
|
|
||||||
export const R3_ELEMENT_REF_FACTORY__POST_NGCC__: FactoryFunction = ivyOn.R3_ELEMENT_REF_FACTORY;
|
|
||||||
export const R3_TEMPLATE_REF_FACTORY__POST_NGCC__: FactoryFunction = ivyOn.R3_TEMPLATE_REF_FACTORY;
|
|
||||||
export const R3_CHANGE_DETECTOR_REF_FACTORY__POST_NGCC__: FactoryFunction =
|
|
||||||
ivyOn.R3_CHANGE_DETECTOR_REF_FACTORY;
|
|
||||||
export const R3_VIEW_CONTAINER_REF_FACTORY__POST_NGCC__: FactoryFunction =
|
|
||||||
ivyOn.R3_VIEW_CONTAINER_REF_FACTORY;
|
|
||||||
export const R3_RENDERER2_FACTORY__POST_NGCC__: FactoryFunction = ivyOn.R3_RENDERER2_FACTORY;
|
|
||||||
|
|
||||||
|
|
||||||
export const R3_ELEMENT_REF_FACTORY__PRE_NGCC__ = noopFactory;
|
|
||||||
export const R3_TEMPLATE_REF_FACTORY__PRE_NGCC__ = noopFactory;
|
|
||||||
export const R3_CHANGE_DETECTOR_REF_FACTORY__PRE_NGCC__ = noopFactory;
|
|
||||||
export const R3_VIEW_CONTAINER_REF_FACTORY__PRE_NGCC__ = noopFactory;
|
|
||||||
export const R3_RENDERER2_FACTORY__PRE_NGCC__ = noopFactory;
|
|
||||||
|
|
||||||
export let R3_ELEMENT_REF_FACTORY = R3_ELEMENT_REF_FACTORY__PRE_NGCC__;
|
|
||||||
export let R3_TEMPLATE_REF_FACTORY = R3_TEMPLATE_REF_FACTORY__PRE_NGCC__;
|
|
||||||
export let R3_CHANGE_DETECTOR_REF_FACTORY = R3_CHANGE_DETECTOR_REF_FACTORY__PRE_NGCC__;
|
|
||||||
export let R3_VIEW_CONTAINER_REF_FACTORY = R3_VIEW_CONTAINER_REF_FACTORY__PRE_NGCC__;
|
|
||||||
export let R3_RENDERER2_FACTORY = R3_RENDERER2_FACTORY__PRE_NGCC__;
|
|
|
@ -1,10 +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 * from './ivy_switch_on';
|
|
|
@ -6,7 +6,8 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {R3_ELEMENT_REF_FACTORY} from '../ivy_switch/runtime/index';
|
import {injectElementRef as render3InjectElementRef} from '../render3/view_engine_compatibility';
|
||||||
|
import {noop} from '../util/noop';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper around a native element inside of a View.
|
* A wrapper around a native element inside of a View.
|
||||||
|
@ -50,5 +51,10 @@ export class ElementRef<T = any> {
|
||||||
constructor(nativeElement: T) { this.nativeElement = nativeElement; }
|
constructor(nativeElement: T) { this.nativeElement = nativeElement; }
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
static __NG_ELEMENT_ID__: () => ElementRef = () => R3_ELEMENT_REF_FACTORY(ElementRef);
|
static __NG_ELEMENT_ID__: () => ElementRef = () => SWITCH_ELEMENT_REF_FACTORY(ElementRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const SWITCH_ELEMENT_REF_FACTORY__POST_R3__ = render3InjectElementRef;
|
||||||
|
const SWITCH_ELEMENT_REF_FACTORY__PRE_R3__ = noop;
|
||||||
|
const SWITCH_ELEMENT_REF_FACTORY: typeof render3InjectElementRef =
|
||||||
|
SWITCH_ELEMENT_REF_FACTORY__PRE_R3__;
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {R3_TEMPLATE_REF_FACTORY} from '../ivy_switch/runtime/index';
|
import {injectTemplateRef as render3InjectTemplateRef} from '../render3/view_engine_compatibility';
|
||||||
|
import {noop} from '../util/noop';
|
||||||
|
|
||||||
import {ElementRef} from './element_ref';
|
import {ElementRef} from './element_ref';
|
||||||
import {EmbeddedViewRef} from './view_ref';
|
import {EmbeddedViewRef} from './view_ref';
|
||||||
|
@ -53,5 +54,10 @@ export abstract class TemplateRef<C> {
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
static __NG_ELEMENT_ID__:
|
static __NG_ELEMENT_ID__:
|
||||||
() => TemplateRef<any> = () => R3_TEMPLATE_REF_FACTORY(TemplateRef, ElementRef)
|
() => TemplateRef<any> = () => SWITCH_TEMPLATE_REF_FACTORY(TemplateRef, ElementRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const SWITCH_TEMPLATE_REF_FACTORY__POST_R3__ = render3InjectTemplateRef;
|
||||||
|
const SWITCH_TEMPLATE_REF_FACTORY__PRE_R3__ = noop;
|
||||||
|
const SWITCH_TEMPLATE_REF_FACTORY: typeof render3InjectTemplateRef =
|
||||||
|
SWITCH_TEMPLATE_REF_FACTORY__PRE_R3__;
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injector} from '../di/injector';
|
import {Injector} from '../di/injector';
|
||||||
import {R3_VIEW_CONTAINER_REF_FACTORY} from '../ivy_switch/runtime/index';
|
import {injectViewContainerRef as render3InjectViewContainerRef} from '../render3/view_engine_compatibility';
|
||||||
|
import {noop} from '../util/noop';
|
||||||
|
|
||||||
import {ComponentFactory, ComponentRef} from './component_factory';
|
import {ComponentFactory, ComponentRef} from './component_factory';
|
||||||
import {ElementRef} from './element_ref';
|
import {ElementRef} from './element_ref';
|
||||||
|
@ -144,5 +145,10 @@ export abstract class ViewContainerRef {
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
static __NG_ELEMENT_ID__:
|
static __NG_ELEMENT_ID__:
|
||||||
() => ViewContainerRef = () => R3_VIEW_CONTAINER_REF_FACTORY(ViewContainerRef, ElementRef)
|
() => ViewContainerRef = () => SWITCH_VIEW_CONTAINER_REF_FACTORY(ViewContainerRef, ElementRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const SWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__ = render3InjectViewContainerRef;
|
||||||
|
const SWITCH_VIEW_CONTAINER_REF_FACTORY__PRE_R3__ = noop;
|
||||||
|
const SWITCH_VIEW_CONTAINER_REF_FACTORY: typeof render3InjectViewContainerRef =
|
||||||
|
SWITCH_VIEW_CONTAINER_REF_FACTORY__PRE_R3__;
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
|
|
||||||
import {ChangeDetectionStrategy} from '../change_detection/constants';
|
import {ChangeDetectionStrategy} from '../change_detection/constants';
|
||||||
import {Provider} from '../di';
|
import {Provider} from '../di';
|
||||||
import {R3_COMPILE_COMPONENT, R3_COMPILE_DIRECTIVE, R3_COMPILE_PIPE} from '../ivy_switch/compiler/index';
|
|
||||||
import {NG_BASE_DEF} from '../render3/fields';
|
import {NG_BASE_DEF} from '../render3/fields';
|
||||||
|
import {compileComponent as render3CompileComponent, compileDirective as render3CompileDirective} from '../render3/jit/directive';
|
||||||
|
import {compilePipe as render3CompilePipe} from '../render3/jit/pipe';
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
import {TypeDecorator, makeDecorator, makePropDecorator} from '../util/decorators';
|
import {TypeDecorator, makeDecorator, makePropDecorator} from '../util/decorators';
|
||||||
|
import {noop} from '../util/noop';
|
||||||
import {fillProperties} from '../util/property';
|
import {fillProperties} from '../util/property';
|
||||||
|
|
||||||
import {ViewEncapsulation} from './view';
|
import {ViewEncapsulation} from './view';
|
||||||
|
@ -350,7 +352,7 @@ export interface Directive {
|
||||||
*/
|
*/
|
||||||
export const Directive: DirectiveDecorator = makeDecorator(
|
export const Directive: DirectiveDecorator = makeDecorator(
|
||||||
'Directive', (dir: Directive = {}) => dir, undefined, undefined,
|
'Directive', (dir: Directive = {}) => dir, undefined, undefined,
|
||||||
(type: Type<any>, meta: Directive) => R3_COMPILE_DIRECTIVE(type, meta));
|
(type: Type<any>, meta: Directive) => SWITCH_COMPILE_DIRECTIVE(type, meta));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component decorator interface
|
* Component decorator interface
|
||||||
|
@ -634,7 +636,8 @@ export interface Component extends Directive {
|
||||||
*/
|
*/
|
||||||
export const Component: ComponentDecorator = makeDecorator(
|
export const Component: ComponentDecorator = makeDecorator(
|
||||||
'Component', (c: Component = {}) => ({changeDetection: ChangeDetectionStrategy.Default, ...c}),
|
'Component', (c: Component = {}) => ({changeDetection: ChangeDetectionStrategy.Default, ...c}),
|
||||||
Directive, undefined, (type: Type<any>, meta: Component) => R3_COMPILE_COMPONENT(type, meta));
|
Directive, undefined,
|
||||||
|
(type: Type<any>, meta: Component) => SWITCH_COMPILE_COMPONENT(type, meta));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of the Pipe decorator / constructor function.
|
* Type of the Pipe decorator / constructor function.
|
||||||
|
@ -682,7 +685,7 @@ export interface Pipe {
|
||||||
*/
|
*/
|
||||||
export const Pipe: PipeDecorator = makeDecorator(
|
export const Pipe: PipeDecorator = makeDecorator(
|
||||||
'Pipe', (p: Pipe) => ({pure: true, ...p}), undefined, undefined,
|
'Pipe', (p: Pipe) => ({pure: true, ...p}), undefined, undefined,
|
||||||
(type: Type<any>, meta: Pipe) => R3_COMPILE_PIPE(type, meta));
|
(type: Type<any>, meta: Pipe) => SWITCH_COMPILE_PIPE(type, meta));
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -949,3 +952,17 @@ export interface HostListener {
|
||||||
*/
|
*/
|
||||||
export const HostListener: HostListenerDecorator =
|
export const HostListener: HostListenerDecorator =
|
||||||
makePropDecorator('HostListener', (eventName?: string, args?: string[]) => ({eventName, args}));
|
makePropDecorator('HostListener', (eventName?: string, args?: string[]) => ({eventName, args}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const SWITCH_COMPILE_COMPONENT__POST_R3__ = render3CompileComponent;
|
||||||
|
export const SWITCH_COMPILE_DIRECTIVE__POST_R3__ = render3CompileDirective;
|
||||||
|
export const SWITCH_COMPILE_PIPE__POST_R3__ = render3CompilePipe;
|
||||||
|
|
||||||
|
const SWITCH_COMPILE_COMPONENT__PRE_R3__ = noop;
|
||||||
|
const SWITCH_COMPILE_DIRECTIVE__PRE_R3__ = noop;
|
||||||
|
const SWITCH_COMPILE_PIPE__PRE_R3__ = noop;
|
||||||
|
|
||||||
|
const SWITCH_COMPILE_COMPONENT: typeof render3CompileComponent = SWITCH_COMPILE_COMPONENT__PRE_R3__;
|
||||||
|
const SWITCH_COMPILE_DIRECTIVE: typeof render3CompileDirective = SWITCH_COMPILE_DIRECTIVE__PRE_R3__;
|
||||||
|
const SWITCH_COMPILE_PIPE: typeof render3CompilePipe = SWITCH_COMPILE_PIPE__PRE_R3__;
|
||||||
|
|
|
@ -7,8 +7,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ApplicationRef} from '../application_ref';
|
import {ApplicationRef} from '../application_ref';
|
||||||
|
import {InjectorType, defineInjector} from '../di/defs';
|
||||||
import {Provider} from '../di/provider';
|
import {Provider} from '../di/provider';
|
||||||
import {R3_COMPILE_NGMODULE} from '../ivy_switch/compiler/index';
|
import {convertInjectableProviderToFactory} from '../di/util';
|
||||||
|
import {compileNgModule as render3CompileNgModule} from '../render3/jit/module';
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
import {TypeDecorator, makeDecorator} from '../util/decorators';
|
import {TypeDecorator, makeDecorator} from '../util/decorators';
|
||||||
|
|
||||||
|
@ -334,7 +336,7 @@ export const NgModule: NgModuleDecorator = makeDecorator(
|
||||||
* * The `imports` and `exports` options bring in members from other modules, and make
|
* * The `imports` and `exports` options bring in members from other modules, and make
|
||||||
* this module's members available to others.
|
* this module's members available to others.
|
||||||
*/
|
*/
|
||||||
(type: Type<any>, meta: NgModule) => R3_COMPILE_NGMODULE(type, meta));
|
(type: Type<any>, meta: NgModule) => SWITCH_COMPILE_NGMODULE(type, meta));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description
|
* @description
|
||||||
|
@ -356,3 +358,21 @@ export const NgModule: NgModuleDecorator = makeDecorator(
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export interface DoBootstrap { ngDoBootstrap(appRef: ApplicationRef): void; }
|
export interface DoBootstrap { ngDoBootstrap(appRef: ApplicationRef): void; }
|
||||||
|
|
||||||
|
function preR3NgModuleCompile(moduleType: InjectorType<any>, metadata: NgModule): void {
|
||||||
|
let imports = (metadata && metadata.imports) || [];
|
||||||
|
if (metadata && metadata.exports) {
|
||||||
|
imports = [...imports, metadata.exports];
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleType.ngInjectorDef = defineInjector({
|
||||||
|
factory: convertInjectableProviderToFactory(moduleType, {useClass: moduleType}),
|
||||||
|
providers: metadata && metadata.providers,
|
||||||
|
imports: imports,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const SWITCH_COMPILE_NGMODULE__POST_R3__ = render3CompileNgModule;
|
||||||
|
const SWITCH_COMPILE_NGMODULE__PRE_R3__ = preR3NgModuleCompile;
|
||||||
|
const SWITCH_COMPILE_NGMODULE: typeof render3CompileNgModule = SWITCH_COMPILE_NGMODULE__PRE_R3__;
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
|
|
||||||
import {InjectionToken} from '../di/injection_token';
|
import {InjectionToken} from '../di/injection_token';
|
||||||
import {Injector} from '../di/injector';
|
import {Injector} from '../di/injector';
|
||||||
import {R3_RENDERER2_FACTORY} from '../ivy_switch/runtime/index';
|
|
||||||
import {ViewEncapsulation} from '../metadata/view';
|
import {ViewEncapsulation} from '../metadata/view';
|
||||||
|
import {injectRenderer2 as render3InjectRenderer2} from '../render3/view_engine_compatibility';
|
||||||
|
import {noop} from '../util/noop';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -370,5 +371,10 @@ export abstract class Renderer2 {
|
||||||
callback: (event: any) => boolean | void): () => void;
|
callback: (event: any) => boolean | void): () => void;
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
static __NG_ELEMENT_ID__: () => Renderer2 = () => R3_RENDERER2_FACTORY();
|
static __NG_ELEMENT_ID__: () => Renderer2 = () => SWITCH_RENDERER2_FACTORY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const SWITCH_RENDERER2_FACTORY__POST_R3__ = render3InjectRenderer2;
|
||||||
|
const SWITCH_RENDERER2_FACTORY__PRE_R3__ = noop;
|
||||||
|
const SWITCH_RENDERER2_FACTORY: typeof render3InjectRenderer2 = SWITCH_RENDERER2_FACTORY__PRE_R3__;
|
||||||
|
|
|
@ -6,4 +6,6 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './ivy_switch_on';
|
export function noop(...args: any[]): any {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ import {InjectableDef, getInjectableDef} from '../di/defs';
|
||||||
import {InjectableType} from '../di/injectable';
|
import {InjectableType} from '../di/injectable';
|
||||||
import {ErrorHandler} from '../error_handler';
|
import {ErrorHandler} from '../error_handler';
|
||||||
import {isDevMode} from '../is_dev_mode';
|
import {isDevMode} from '../is_dev_mode';
|
||||||
import {ivyEnabled} from '../ivy_switch/compiler/index';
|
import {ivyEnabled} from '../ivy_switch';
|
||||||
import {ComponentFactory} from '../linker/component_factory';
|
import {ComponentFactory} from '../linker/component_factory';
|
||||||
import {NgModuleRef} from '../linker/ng_module_factory';
|
import {NgModuleRef} from '../linker/ng_module_factory';
|
||||||
import {Renderer2, RendererFactory2, RendererStyleFlags2, RendererType2} from '../render/api';
|
import {Renderer2, RendererFactory2, RendererStyleFlags2, RendererType2} from '../render/api';
|
||||||
|
|
|
@ -158,15 +158,6 @@
|
||||||
{
|
{
|
||||||
"name": "QUERIES"
|
"name": "QUERIES"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "R3_ELEMENT_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_TEMPLATE_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_VIEW_CONTAINER_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "RENDERER"
|
"name": "RENDERER"
|
||||||
},
|
},
|
||||||
|
@ -185,6 +176,15 @@
|
||||||
{
|
{
|
||||||
"name": "SANITIZER"
|
"name": "SANITIZER"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_ELEMENT_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_TEMPLATE_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_VIEW_CONTAINER_REF_FACTORY"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SimpleKeyframePlayer"
|
"name": "SimpleKeyframePlayer"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1250,24 +1250,6 @@
|
||||||
{
|
{
|
||||||
"name": "Quote"
|
"name": "Quote"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "R3_CHANGE_DETECTOR_REF_FACTORY$1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_COMPILE_INJECTABLE$1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_ELEMENT_REF_FACTORY$1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_RENDERER2_FACTORY$1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_TEMPLATE_REF_FACTORY$1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_VIEW_CONTAINER_REF_FACTORY$1"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "ReadKeyExpr"
|
"name": "ReadKeyExpr"
|
||||||
},
|
},
|
||||||
|
@ -1352,6 +1334,24 @@
|
||||||
{
|
{
|
||||||
"name": "STYLE_PREFIX"
|
"name": "STYLE_PREFIX"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_CHANGE_DETECTOR_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_COMPILE_INJECTABLE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_ELEMENT_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_RENDERER2_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_TEMPLATE_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_VIEW_CONTAINER_REF_FACTORY"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SafeMethodCall"
|
"name": "SafeMethodCall"
|
||||||
},
|
},
|
||||||
|
@ -1599,10 +1599,10 @@
|
||||||
"name": "URL_WITH_SCHEMA_REGEXP"
|
"name": "URL_WITH_SCHEMA_REGEXP"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "USE_VALUE"
|
"name": "USE_VALUE$1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "USE_VALUE$3"
|
"name": "USE_VALUE$2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "UnsubscriptionError"
|
"name": "UnsubscriptionError"
|
||||||
|
@ -2460,7 +2460,7 @@
|
||||||
"name": "compileNgModuleFactory"
|
"name": "compileNgModuleFactory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "compileNgModuleFactory__PRE_NGCC__"
|
"name": "compileNgModuleFactory__PRE_R3__"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "componentFactoryName"
|
"name": "componentFactoryName"
|
||||||
|
@ -3411,10 +3411,10 @@
|
||||||
"name": "noop$1"
|
"name": "noop$1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "noop$3"
|
"name": "noop$2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "noopFactory"
|
"name": "noop$3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "noopScope"
|
"name": "noopScope"
|
||||||
|
@ -3476,9 +3476,6 @@
|
||||||
{
|
{
|
||||||
"name": "platformCoreDynamic"
|
"name": "platformCoreDynamic"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "preR3InjectableCompile"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "preparseElement"
|
"name": "preparseElement"
|
||||||
},
|
},
|
||||||
|
@ -3554,6 +3551,9 @@
|
||||||
{
|
{
|
||||||
"name": "removeWhitespaces"
|
"name": "removeWhitespaces"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "render2CompileInjectable"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "renderAttachEmbeddedView"
|
"name": "renderAttachEmbeddedView"
|
||||||
},
|
},
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
"name": "THROW_IF_NOT_FOUND"
|
"name": "THROW_IF_NOT_FOUND"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "USE_VALUE"
|
"name": "USE_VALUE$1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "UnsubscriptionErrorImpl"
|
"name": "UnsubscriptionErrorImpl"
|
||||||
|
@ -147,12 +147,12 @@
|
||||||
"name": "providerToRecord"
|
"name": "providerToRecord"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "resolveForwardRef"
|
"name": "resolveForwardRef$1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "setCurrentInjector"
|
"name": "setCurrentInjector"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "stringify"
|
"name": "stringify$1"
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -152,15 +152,6 @@
|
||||||
{
|
{
|
||||||
"name": "QUERIES"
|
"name": "QUERIES"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "R3_ELEMENT_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_TEMPLATE_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_VIEW_CONTAINER_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "RENDERER"
|
"name": "RENDERER"
|
||||||
},
|
},
|
||||||
|
@ -179,6 +170,15 @@
|
||||||
{
|
{
|
||||||
"name": "SANITIZER"
|
"name": "SANITIZER"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_ELEMENT_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_TEMPLATE_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_VIEW_CONTAINER_REF_FACTORY"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SkipSelf"
|
"name": "SkipSelf"
|
||||||
},
|
},
|
||||||
|
|
|
@ -140,9 +140,6 @@
|
||||||
{
|
{
|
||||||
"name": "Compiler"
|
"name": "Compiler"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "CompilerFactory"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "ComponentFactory"
|
"name": "ComponentFactory"
|
||||||
},
|
},
|
||||||
|
@ -680,21 +677,6 @@
|
||||||
{
|
{
|
||||||
"name": "R3Injector"
|
"name": "R3Injector"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "R3_CHANGE_DETECTOR_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_ELEMENT_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_RENDERER2_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_TEMPLATE_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "R3_VIEW_CONTAINER_REF_FACTORY"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "REMOVE_EVENT_LISTENER"
|
"name": "REMOVE_EVENT_LISTENER"
|
||||||
},
|
},
|
||||||
|
@ -758,6 +740,21 @@
|
||||||
{
|
{
|
||||||
"name": "SURROGATE_PAIR_REGEXP"
|
"name": "SURROGATE_PAIR_REGEXP"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_CHANGE_DETECTOR_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_ELEMENT_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_RENDERER2_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_TEMPLATE_REF_FACTORY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SWITCH_VIEW_CONTAINER_REF_FACTORY"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "SafeHtmlImpl"
|
"name": "SafeHtmlImpl"
|
||||||
},
|
},
|
||||||
|
@ -1281,7 +1278,7 @@
|
||||||
"name": "compileNgModuleFactory"
|
"name": "compileNgModuleFactory"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "compileNgModuleFactory__PRE_NGCC__"
|
"name": "compileNgModuleFactory__POST_R3__"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "componentRefresh"
|
"name": "componentRefresh"
|
||||||
|
@ -2157,10 +2154,10 @@
|
||||||
"name": "noSideEffects"
|
"name": "noSideEffects"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "noop$1"
|
"name": "noop$2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "noop$2"
|
"name": "noop$3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "noopScope"
|
"name": "noopScope"
|
||||||
|
|
|
@ -11,7 +11,7 @@ import 'reflect-metadata';
|
||||||
import {InjectorDef, defineInjectable} from '@angular/core/src/di/defs';
|
import {InjectorDef, defineInjectable} from '@angular/core/src/di/defs';
|
||||||
import {Injectable} from '@angular/core/src/di/injectable';
|
import {Injectable} from '@angular/core/src/di/injectable';
|
||||||
import {inject, setCurrentInjector} from '@angular/core/src/di/injector';
|
import {inject, setCurrentInjector} from '@angular/core/src/di/injector';
|
||||||
import {ivyEnabled} from '@angular/core/src/ivy_switch/compiler/index';
|
import {ivyEnabled} from '@angular/core/src/ivy_switch';
|
||||||
import {Component, HostBinding, HostListener, Input, Output, Pipe} from '@angular/core/src/metadata/directives';
|
import {Component, HostBinding, HostListener, Input, Output, Pipe} from '@angular/core/src/metadata/directives';
|
||||||
import {NgModule, NgModuleDef} from '@angular/core/src/metadata/ng_module';
|
import {NgModule, NgModuleDef} from '@angular/core/src/metadata/ng_module';
|
||||||
import {ComponentDef, PipeDef} from '@angular/core/src/render3/interfaces/definition';
|
import {ComponentDef, PipeDef} from '@angular/core/src/render3/interfaces/definition';
|
||||||
|
|
|
@ -13,8 +13,12 @@ import {ViewContainerRef} from '@angular/core/src/linker/view_container_ref';
|
||||||
import {Renderer2} from '@angular/core/src/render/api';
|
import {Renderer2} from '@angular/core/src/render/api';
|
||||||
import {stringifyElement} from '@angular/platform-browser/testing/src/browser_util';
|
import {stringifyElement} from '@angular/platform-browser/testing/src/browser_util';
|
||||||
|
|
||||||
|
import {SWITCH_CHANGE_DETECTOR_REF_FACTORY__POST_R3__ as R3_CHANGE_DETECTOR_REF_FACTORY} from '../../src/change_detection/change_detector_ref';
|
||||||
import {Injector} from '../../src/di/injector';
|
import {Injector} from '../../src/di/injector';
|
||||||
import {R3_CHANGE_DETECTOR_REF_FACTORY, R3_ELEMENT_REF_FACTORY, R3_RENDERER2_FACTORY, R3_TEMPLATE_REF_FACTORY, R3_VIEW_CONTAINER_REF_FACTORY} from '../../src/ivy_switch/runtime/ivy_switch_on';
|
import {SWITCH_ELEMENT_REF_FACTORY__POST_R3__ as R3_ELEMENT_REF_FACTORY} from '../../src/linker/element_ref';
|
||||||
|
import {SWITCH_TEMPLATE_REF_FACTORY__POST_R3__ as R3_TEMPLATE_REF_FACTORY} from '../../src/linker/template_ref';
|
||||||
|
import {SWITCH_VIEW_CONTAINER_REF_FACTORY__POST_R3__ as R3_VIEW_CONTAINER_REF_FACTORY} from '../../src/linker/view_container_ref';
|
||||||
|
import {SWITCH_RENDERER2_FACTORY__POST_R3__ as R3_RENDERER2_FACTORY} from '../../src/render/api';
|
||||||
import {CreateComponentOptions} from '../../src/render3/component';
|
import {CreateComponentOptions} from '../../src/render3/component';
|
||||||
import {discoverDirectives, getContext, isComponentInstance} from '../../src/render3/context_discovery';
|
import {discoverDirectives, getContext, isComponentInstance} from '../../src/render3/context_discovery';
|
||||||
import {extractDirectiveDef, extractPipeDef} from '../../src/render3/definition';
|
import {extractDirectiveDef, extractPipeDef} from '../../src/render3/definition';
|
||||||
|
|
Loading…
Reference in New Issue