refactor(ivy): move ngcc into a higher level folder (#29092)
PR Close #29092
This commit is contained in:
parent
cf4718c366
commit
a770aa231d
|
@ -34,9 +34,9 @@ ng_package(
|
||||||
visibility = [
|
visibility = [
|
||||||
"//packages/bazel/test/ng_package:__pkg__",
|
"//packages/bazel/test/ng_package:__pkg__",
|
||||||
"//packages/compiler-cli/integrationtest:__pkg__",
|
"//packages/compiler-cli/integrationtest:__pkg__",
|
||||||
|
"//packages/compiler-cli/ngcc/test:__pkg__",
|
||||||
"//packages/compiler-cli/test:__pkg__",
|
"//packages/compiler-cli/test:__pkg__",
|
||||||
"//packages/compiler-cli/test/diagnostics:__pkg__",
|
"//packages/compiler-cli/test/diagnostics:__pkg__",
|
||||||
"//packages/compiler-cli/test/ngcc:__pkg__",
|
|
||||||
"//packages/compiler-cli/test/transformers:__pkg__",
|
"//packages/compiler-cli/test/transformers:__pkg__",
|
||||||
"//packages/compiler/test:__pkg__",
|
"//packages/compiler/test:__pkg__",
|
||||||
"//packages/language-service/test:__pkg__",
|
"//packages/language-service/test:__pkg__",
|
||||||
|
|
|
@ -60,6 +60,6 @@ npm_package(
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":compiler-cli",
|
":compiler-cli",
|
||||||
"//packages/compiler-cli/src/ngcc",
|
"//packages/compiler-cli/ngcc",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,7 +10,7 @@ This conversion will allow such "legacy" packages to be used by the Ivy renderin
|
||||||
The project is built using Bazel:
|
The project is built using Bazel:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn bazel build //packages/compiler-cli/src/ngcc
|
yarn bazel build //packages/compiler-cli/ngcc
|
||||||
```
|
```
|
||||||
|
|
||||||
## Unit Testing
|
## Unit Testing
|
||||||
|
@ -18,7 +18,7 @@ yarn bazel build //packages/compiler-cli/src/ngcc
|
||||||
The unit tests are built and run using Bazel:
|
The unit tests are built and run using Bazel:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn bazel test //packages/compiler-cli/src/ngcc/test
|
yarn bazel test //packages/compiler-cli/ngcc/test
|
||||||
```
|
```
|
||||||
|
|
||||||
## Integration Testing
|
## Integration Testing
|
||||||
|
@ -26,5 +26,5 @@ yarn bazel test //packages/compiler-cli/src/ngcc/test
|
||||||
There are tests that check the behavior of the overall executable:
|
There are tests that check the behavior of the overall executable:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn bazel test //packages/compiler-cli/test/ngcc
|
yarn bazel test //packages/compiler-cli/ngcc/test:integration
|
||||||
```
|
```
|
|
@ -10,13 +10,13 @@ import * as path from 'canonical-path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {BaseDefDecoratorHandler, ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ReferencesRegistry, ResourceLoader} from '../../../ngtsc/annotations';
|
import {BaseDefDecoratorHandler, ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ReferencesRegistry, ResourceLoader} from '../../../src/ngtsc/annotations';
|
||||||
import {CycleAnalyzer, ImportGraph} from '../../../ngtsc/cycles';
|
import {CycleAnalyzer, ImportGraph} from '../../../src/ngtsc/cycles';
|
||||||
import {AbsoluteModuleStrategy, LocalIdentifierStrategy, LogicalProjectStrategy, ModuleResolver, NOOP_DEFAULT_IMPORT_RECORDER, ReferenceEmitter} from '../../../ngtsc/imports';
|
import {AbsoluteModuleStrategy, LocalIdentifierStrategy, LogicalProjectStrategy, ModuleResolver, NOOP_DEFAULT_IMPORT_RECORDER, ReferenceEmitter} from '../../../src/ngtsc/imports';
|
||||||
import {PartialEvaluator} from '../../../ngtsc/partial_evaluator';
|
import {PartialEvaluator} from '../../../src/ngtsc/partial_evaluator';
|
||||||
import {AbsoluteFsPath, LogicalFileSystem} from '../../../ngtsc/path';
|
import {AbsoluteFsPath, LogicalFileSystem} from '../../../src/ngtsc/path';
|
||||||
import {LocalModuleScopeRegistry, MetadataDtsModuleScopeResolver} from '../../../ngtsc/scope';
|
import {LocalModuleScopeRegistry, MetadataDtsModuleScopeResolver} from '../../../src/ngtsc/scope';
|
||||||
import {CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence} from '../../../ngtsc/transform';
|
import {CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence} from '../../../src/ngtsc/transform';
|
||||||
import {DecoratedClass} from '../host/decorated_class';
|
import {DecoratedClass} from '../host/decorated_class';
|
||||||
import {NgccReflectionHost} from '../host/ngcc_host';
|
import {NgccReflectionHost} from '../host/ngcc_host';
|
||||||
import {isDefined} from '../utils';
|
import {isDefined} from '../utils';
|
|
@ -7,9 +7,9 @@
|
||||||
*/
|
*/
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {ReferencesRegistry} from '../../../ngtsc/annotations';
|
import {ReferencesRegistry} from '../../../src/ngtsc/annotations';
|
||||||
import {Reference} from '../../../ngtsc/imports';
|
import {Reference} from '../../../src/ngtsc/imports';
|
||||||
import {Declaration} from '../../../ngtsc/reflection';
|
import {Declaration} from '../../../src/ngtsc/reflection';
|
||||||
import {NgccReflectionHost} from '../host/ngcc_host';
|
import {NgccReflectionHost} from '../host/ngcc_host';
|
||||||
import {isDefined} from '../utils';
|
import {isDefined} from '../utils';
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import {ReferencesRegistry} from '../../../ngtsc/annotations';
|
import {ReferencesRegistry} from '../../../src/ngtsc/annotations';
|
||||||
import {Reference} from '../../../ngtsc/imports';
|
import {Reference} from '../../../src/ngtsc/imports';
|
||||||
import {Declaration, ReflectionHost} from '../../../ngtsc/reflection';
|
import {Declaration, ReflectionHost} from '../../../src/ngtsc/reflection';
|
||||||
import {hasNameIdentifier} from '../utils';
|
import {hasNameIdentifier} from '../utils';
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {Declaration} from '../../../ngtsc/reflection';
|
import {Declaration} from '../../../src/ngtsc/reflection';
|
||||||
import {NgccReflectionHost} from '../host/ngcc_host';
|
import {NgccReflectionHost} from '../host/ngcc_host';
|
||||||
import {hasNameIdentifier, isDefined} from '../utils';
|
import {hasNameIdentifier, isDefined} from '../utils';
|
||||||
import {NgccReferencesRegistry} from './ngcc_references_registry';
|
import {NgccReferencesRegistry} from './ngcc_references_registry';
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import {Decorator} from '../../../ngtsc/reflection';
|
import {Decorator} from '../../../src/ngtsc/reflection';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple container that holds the details of a decorated class that has been
|
* A simple container that holds the details of a decorated class that has been
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {ClassMember, ClassMemberKind, CtorParameter, Decorator, Import, TypeScriptReflectionHost, reflectObjectLiteral} from '../../../ngtsc/reflection';
|
import {ClassMember, ClassMemberKind, CtorParameter, Decorator, Import, TypeScriptReflectionHost, reflectObjectLiteral} from '../../../src/ngtsc/reflection';
|
||||||
import {BundleProgram} from '../packages/bundle_program';
|
import {BundleProgram} from '../packages/bundle_program';
|
||||||
import {findAll, getNameText, isDefined} from '../utils';
|
import {findAll, getNameText, isDefined} from '../utils';
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {ClassMember, ClassMemberKind, Declaration, Decorator, FunctionDefinition, Parameter, reflectObjectLiteral} from '../../../ngtsc/reflection';
|
import {ClassMember, ClassMemberKind, Declaration, Decorator, FunctionDefinition, Parameter, reflectObjectLiteral} from '../../../src/ngtsc/reflection';
|
||||||
import {getNameText, hasNameIdentifier} from '../utils';
|
import {getNameText, hasNameIdentifier} from '../utils';
|
||||||
|
|
||||||
import {Esm2015ReflectionHost, ParamInfo, getPropertyValueFromSymbol, isAssignmentStatement} from './esm2015_host';
|
import {Esm2015ReflectionHost, ParamInfo, getPropertyValueFromSymbol, isAssignmentStatement} from './esm2015_host';
|
|
@ -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 * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import {ReflectionHost} from '../../../ngtsc/reflection';
|
import {ReflectionHost} from '../../../src/ngtsc/reflection';
|
||||||
import {DecoratedClass} from './decorated_class';
|
import {DecoratedClass} from './decorated_class';
|
||||||
|
|
||||||
export const PRE_R3_MARKER = '__PRE_R3__';
|
export const PRE_R3_MARKER = '__PRE_R3__';
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {AbsoluteFsPath} from '../../../ngtsc/path';
|
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
|
||||||
|
|
||||||
import {BundleProgram, makeBundleProgram} from './bundle_program';
|
import {BundleProgram, makeBundleProgram} from './bundle_program';
|
||||||
import {EntryPoint, EntryPointFormat} from './entry_point';
|
import {EntryPoint, EntryPointFormat} from './entry_point';
|
|
@ -13,7 +13,7 @@ import {CompiledClass} from '../analysis/decoration_analyzer';
|
||||||
import {RedundantDecoratorMap, Renderer, stripExtension} from './renderer';
|
import {RedundantDecoratorMap, Renderer, stripExtension} from './renderer';
|
||||||
import {EntryPointBundle} from '../packages/entry_point_bundle';
|
import {EntryPointBundle} from '../packages/entry_point_bundle';
|
||||||
import {ExportInfo} from '../analysis/private_declarations_analyzer';
|
import {ExportInfo} from '../analysis/private_declarations_analyzer';
|
||||||
import {isDtsPath} from '../../../ngtsc/util/src/typescript';
|
import {isDtsPath} from '../../../src/ngtsc/util/src/typescript';
|
||||||
|
|
||||||
export class EsmRenderer extends Renderer {
|
export class EsmRenderer extends Renderer {
|
||||||
constructor(
|
constructor(
|
|
@ -7,7 +7,7 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ImportRewriter, validateAndRewriteCoreSymbol} from '../../../ngtsc/imports';
|
import {ImportRewriter, validateAndRewriteCoreSymbol} from '../../../src/ngtsc/imports';
|
||||||
|
|
||||||
export class NgccFlatImportRewriter implements ImportRewriter {
|
export class NgccFlatImportRewriter implements ImportRewriter {
|
||||||
shouldImportSymbol(symbol: string, specifier: string): boolean {
|
shouldImportSymbol(symbol: string, specifier: string): boolean {
|
|
@ -15,7 +15,7 @@ import * as ts from 'typescript';
|
||||||
|
|
||||||
import {NoopImportRewriter, ImportRewriter, R3SymbolsImportRewriter, NOOP_DEFAULT_IMPORT_RECORDER} from '@angular/compiler-cli/src/ngtsc/imports';
|
import {NoopImportRewriter, ImportRewriter, R3SymbolsImportRewriter, NOOP_DEFAULT_IMPORT_RECORDER} from '@angular/compiler-cli/src/ngtsc/imports';
|
||||||
import {CompileResult} from '@angular/compiler-cli/src/ngtsc/transform';
|
import {CompileResult} from '@angular/compiler-cli/src/ngtsc/transform';
|
||||||
import {translateStatement, translateType, ImportManager} from '../../../ngtsc/translator';
|
import {translateStatement, translateType, ImportManager} from '../../../src/ngtsc/translator';
|
||||||
import {NgccFlatImportRewriter} from './ngcc_import_rewriter';
|
import {NgccFlatImportRewriter} from './ngcc_import_rewriter';
|
||||||
import {CompiledClass, CompiledFile, DecorationAnalyses} from '../analysis/decoration_analyzer';
|
import {CompiledClass, CompiledFile, DecorationAnalyses} from '../analysis/decoration_analyzer';
|
||||||
import {ModuleWithProvidersInfo, ModuleWithProvidersAnalyses} from '../analysis/module_with_providers_analyzer';
|
import {ModuleWithProvidersInfo, ModuleWithProvidersAnalyses} from '../analysis/module_with_providers_analyzer';
|
|
@ -5,17 +5,19 @@ package(default_visibility = ["//visibility:public"])
|
||||||
ts_library(
|
ts_library(
|
||||||
name = "test_lib",
|
name = "test_lib",
|
||||||
testonly = True,
|
testonly = True,
|
||||||
srcs = glob([
|
srcs = glob(
|
||||||
"**/*.ts",
|
["**/*.ts"],
|
||||||
]),
|
exclude = ["integration/**/*.ts"],
|
||||||
|
),
|
||||||
deps = [
|
deps = [
|
||||||
"//packages/compiler-cli/src/ngcc",
|
"//packages/compiler-cli/ngcc",
|
||||||
"//packages/compiler-cli/src/ngtsc/imports",
|
"//packages/compiler-cli/src/ngtsc/imports",
|
||||||
"//packages/compiler-cli/src/ngtsc/partial_evaluator",
|
"//packages/compiler-cli/src/ngtsc/partial_evaluator",
|
||||||
"//packages/compiler-cli/src/ngtsc/path",
|
"//packages/compiler-cli/src/ngtsc/path",
|
||||||
"//packages/compiler-cli/src/ngtsc/reflection",
|
"//packages/compiler-cli/src/ngtsc/reflection",
|
||||||
"//packages/compiler-cli/src/ngtsc/testing",
|
"//packages/compiler-cli/src/ngtsc/testing",
|
||||||
"//packages/compiler-cli/src/ngtsc/transform",
|
"//packages/compiler-cli/src/ngtsc/transform",
|
||||||
|
"//packages/compiler-cli/test:test_utils",
|
||||||
"@npm//@types/convert-source-map",
|
"@npm//@types/convert-source-map",
|
||||||
"@npm//@types/mock-fs",
|
"@npm//@types/mock-fs",
|
||||||
"@npm//canonical-path",
|
"@npm//canonical-path",
|
||||||
|
@ -34,3 +36,34 @@ jasmine_node_test(
|
||||||
"@npm//convert-source-map",
|
"@npm//convert-source-map",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ts_library(
|
||||||
|
name = "integration_lib",
|
||||||
|
testonly = True,
|
||||||
|
srcs = glob(
|
||||||
|
["integration/**/*.ts"],
|
||||||
|
),
|
||||||
|
deps = [
|
||||||
|
"//packages/compiler-cli/ngcc",
|
||||||
|
"//packages/compiler-cli/test:test_utils",
|
||||||
|
"@npm//@types/mock-fs",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
jasmine_node_test(
|
||||||
|
name = "integration",
|
||||||
|
bootstrap = ["angular/tools/testing/init_node_no_angular_spec.js"],
|
||||||
|
data = [
|
||||||
|
"//packages/common:npm_package",
|
||||||
|
"//packages/core:npm_package",
|
||||||
|
"@npm//rxjs",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
":integration_lib",
|
||||||
|
"//packages/common",
|
||||||
|
"//tools/testing:node_no_angular",
|
||||||
|
"@npm//canonical-path",
|
||||||
|
"@npm//convert-source-map",
|
||||||
|
"@npm//shelljs",
|
||||||
|
],
|
||||||
|
)
|
|
@ -7,9 +7,9 @@
|
||||||
*/
|
*/
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {AbsoluteFsPath} from '../../../ngtsc/path';
|
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
|
||||||
import {Decorator} from '../../../ngtsc/reflection';
|
import {Decorator} from '../../../src/ngtsc/reflection';
|
||||||
import {DecoratorHandler, DetectResult} from '../../../ngtsc/transform';
|
import {DecoratorHandler, DetectResult} from '../../../src/ngtsc/transform';
|
||||||
import {CompiledClass, DecorationAnalyses, DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
|
import {CompiledClass, DecorationAnalyses, DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
|
||||||
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
||||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {Reference} from '../../../ngtsc/imports';
|
import {Reference} from '../../../src/ngtsc/imports';
|
||||||
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
||||||
import {PrivateDeclarationsAnalyzer} from '../../src/analysis/private_declarations_analyzer';
|
import {PrivateDeclarationsAnalyzer} from '../../src/analysis/private_declarations_analyzer';
|
||||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
|
@ -8,10 +8,10 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {Reference} from '../../../ngtsc/imports';
|
import {Reference} from '../../../src/ngtsc/imports';
|
||||||
import {PartialEvaluator} from '../../../ngtsc/partial_evaluator';
|
import {PartialEvaluator} from '../../../src/ngtsc/partial_evaluator';
|
||||||
import {TypeScriptReflectionHost} from '../../../ngtsc/reflection';
|
import {TypeScriptReflectionHost} from '../../../src/ngtsc/reflection';
|
||||||
import {getDeclaration, makeProgram} from '../../../ngtsc/testing/in_memory_typescript';
|
import {getDeclaration, makeProgram} from '../../../src/ngtsc/testing/in_memory_typescript';
|
||||||
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
||||||
|
|
||||||
describe('NgccReferencesRegistry', () => {
|
describe('NgccReferencesRegistry', () => {
|
|
@ -7,13 +7,13 @@
|
||||||
*/
|
*/
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {AbsoluteFsPath} from '../../../ngtsc/path';
|
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
|
||||||
import {makeProgram} from '../../../ngtsc/testing/in_memory_typescript';
|
import {makeProgram} from '../../../src/ngtsc/testing/in_memory_typescript';
|
||||||
import {BundleProgram} from '../../src/packages/bundle_program';
|
import {BundleProgram} from '../../src/packages/bundle_program';
|
||||||
import {EntryPointFormat} from '../../src/packages/entry_point';
|
import {EntryPointFormat} from '../../src/packages/entry_point';
|
||||||
import {EntryPointBundle} from '../../src/packages/entry_point_bundle';
|
import {EntryPointBundle} from '../../src/packages/entry_point_bundle';
|
||||||
|
|
||||||
export {getDeclaration} from '../../../ngtsc/testing/in_memory_typescript';
|
export {getDeclaration} from '../../../src/ngtsc/testing/in_memory_typescript';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {ClassMemberKind, Import} from '../../../ngtsc/reflection';
|
import {ClassMemberKind, Import} from '../../../src/ngtsc/reflection';
|
||||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
||||||
import {convertToDirectTsLibImport, getDeclaration, makeTestProgram} from '../helpers/utils';
|
import {convertToDirectTsLibImport, getDeclaration, makeTestProgram} from '../helpers/utils';
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {ClassMemberKind, Import} from '../../../ngtsc/reflection';
|
import {ClassMemberKind, Import} from '../../../src/ngtsc/reflection';
|
||||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
||||||
import {getDeclaration, makeTestBundleProgram, makeTestProgram} from '../helpers/utils';
|
import {getDeclaration, makeTestBundleProgram, makeTestProgram} from '../helpers/utils';
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {ClassMemberKind, Import} from '../../../ngtsc/reflection';
|
import {ClassMemberKind, Import} from '../../../src/ngtsc/reflection';
|
||||||
import {Esm5ReflectionHost} from '../../src/host/esm5_host';
|
import {Esm5ReflectionHost} from '../../src/host/esm5_host';
|
||||||
import {convertToDirectTsLibImport, getDeclaration, makeTestProgram} from '../helpers/utils';
|
import {convertToDirectTsLibImport, getDeclaration, makeTestProgram} from '../helpers/utils';
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {ClassMemberKind, Import} from '../../../ngtsc/reflection';
|
import {ClassMemberKind, Import} from '../../../src/ngtsc/reflection';
|
||||||
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
import {Esm2015ReflectionHost} from '../../src/host/esm2015_host';
|
||||||
import {Esm5ReflectionHost} from '../../src/host/esm5_host';
|
import {Esm5ReflectionHost} from '../../src/host/esm5_host';
|
||||||
import {getDeclaration, makeTestBundleProgram, makeTestProgram} from '../helpers/utils';
|
import {getDeclaration, makeTestBundleProgram, makeTestProgram} from '../helpers/utils';
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {CtorParameter} from '../../../ngtsc/reflection';
|
import {CtorParameter} from '../../../src/ngtsc/reflection';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that a given list of `CtorParameter`s has `typeValueReference`s of specific `ts.Identifier`
|
* Check that a given list of `CtorParameter`s has `typeValueReference`s of specific `ts.Identifier`
|
|
@ -11,8 +11,8 @@ import * as mockFs from 'mock-fs';
|
||||||
import {join} from 'path';
|
import {join} from 'path';
|
||||||
const Module = require('module');
|
const Module = require('module');
|
||||||
|
|
||||||
import {mainNgcc} from '../../src/ngcc/src/main';
|
import {mainNgcc} from '../../src/main';
|
||||||
import {getAngularPackagesFromRunfiles} from '../runfile_helpers';
|
import {getAngularPackagesFromRunfiles, resolveNpmTreeArtifact} from '../../../test/runfile_helpers';
|
||||||
|
|
||||||
describe('ngcc main()', () => {
|
describe('ngcc main()', () => {
|
||||||
beforeEach(createMockFileSystem);
|
beforeEach(createMockFileSystem);
|
||||||
|
@ -41,7 +41,10 @@ describe('ngcc main()', () => {
|
||||||
|
|
||||||
|
|
||||||
function createMockFileSystem() {
|
function createMockFileSystem() {
|
||||||
mockFs({'/node_modules/@angular': loadAngularPackages()});
|
mockFs({
|
||||||
|
'/node_modules/@angular': loadAngularPackages(),
|
||||||
|
'/node_modules/rxjs': loadDirectory(resolveNpmTreeArtifact('rxjs', 'index.js')),
|
||||||
|
});
|
||||||
spyOn(Module, '_resolveFilename').and.callFake(mockResolve);
|
spyOn(Module, '_resolveFilename').and.callFake(mockResolve);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,22 +87,31 @@ interface Directory {
|
||||||
[pathSegment: string]: string|Directory;
|
[pathSegment: string]: string|Directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mockResolve(p: string): string|null {
|
function mockResolve(request: string): string|null {
|
||||||
if (existsSync(p)) {
|
if (existsSync(request)) {
|
||||||
const stat = statSync(p);
|
const stat = statSync(request);
|
||||||
if (stat.isFile()) {
|
if (stat.isFile()) {
|
||||||
return p;
|
return request;
|
||||||
} else if (stat.isDirectory()) {
|
} else if (stat.isDirectory()) {
|
||||||
const pIndex = mockResolve(p + '/index');
|
const pIndex = mockResolve(request + '/index');
|
||||||
if (pIndex && existsSync(pIndex)) {
|
if (pIndex && existsSync(pIndex)) {
|
||||||
return pIndex;
|
return pIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const ext of ['.js', '.d.ts']) {
|
for (const ext of ['.js', '.d.ts']) {
|
||||||
if (existsSync(p + ext)) {
|
if (existsSync(request + ext)) {
|
||||||
return p + ext;
|
return request + ext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
if (request.indexOf('/node_modules') === 0) {
|
||||||
|
// We already tried adding node_modules so give up.
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return mockResolve(join('/node_modules', request));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadPackage(packageName: string) {
|
||||||
|
return JSON.parse(readFileSync(`/node_modules/${packageName}/package.json`, 'utf8'));
|
||||||
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
import {dirname} from 'canonical-path';
|
import {dirname} from 'canonical-path';
|
||||||
import MagicString from 'magic-string';
|
import MagicString from 'magic-string';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import {AbsoluteFsPath} from '../../../ngtsc/path';
|
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
|
||||||
import {DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
|
import {DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
|
||||||
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
||||||
import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer';
|
import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer';
|
|
@ -8,7 +8,7 @@
|
||||||
import {dirname} from 'canonical-path';
|
import {dirname} from 'canonical-path';
|
||||||
import MagicString from 'magic-string';
|
import MagicString from 'magic-string';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import {AbsoluteFsPath} from '../../../ngtsc/path';
|
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
|
||||||
import {DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
|
import {DecorationAnalyzer} from '../../src/analysis/decoration_analyzer';
|
||||||
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
import {NgccReferencesRegistry} from '../../src/analysis/ngcc_references_registry';
|
||||||
import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer';
|
import {SwitchMarkerAnalyzer} from '../../src/analysis/switch_marker_analyzer';
|
|
@ -5,7 +5,7 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"typings": "index.d.ts",
|
"typings": "index.d.ts",
|
||||||
"bin": {
|
"bin": {
|
||||||
"ivy-ngcc": "./src/ngcc/main-ngcc.js",
|
"ivy-ngcc": "./ngcc/main-ngcc.js",
|
||||||
"ngc": "./src/main.js",
|
"ngc": "./src/main.js",
|
||||||
"ng-xi18n": "./src/extract_i18n.js"
|
"ng-xi18n": "./src/extract_i18n.js"
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,6 +12,7 @@ ts_library(
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
":__subpackages__",
|
":__subpackages__",
|
||||||
|
"//packages/compiler-cli/ngcc/test:__subpackages__",
|
||||||
"//packages/language-service/test:__subpackages__",
|
"//packages/language-service/test:__subpackages__",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
|
|
||||||
|
|
||||||
# Integration tests
|
|
||||||
ts_library(
|
|
||||||
name = "ngcc_lib",
|
|
||||||
testonly = True,
|
|
||||||
srcs = glob([
|
|
||||||
"**/*_spec.ts",
|
|
||||||
]),
|
|
||||||
deps = [
|
|
||||||
"//packages/compiler-cli/src/ngcc",
|
|
||||||
"//packages/compiler-cli/test:test_utils",
|
|
||||||
"@npm//@types/mock-fs",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
jasmine_node_test(
|
|
||||||
name = "ngcc",
|
|
||||||
bootstrap = ["angular/tools/testing/init_node_no_angular_spec.js"],
|
|
||||||
data = [
|
|
||||||
"//packages/common:npm_package",
|
|
||||||
"//packages/core:npm_package",
|
|
||||||
],
|
|
||||||
deps = [
|
|
||||||
":ngcc_lib",
|
|
||||||
"//tools/testing:node_no_angular",
|
|
||||||
"@npm//@types/mock-fs",
|
|
||||||
"@npm//canonical-path",
|
|
||||||
"@npm//convert-source-map",
|
|
||||||
"@npm//shelljs",
|
|
||||||
"@npm//yargs",
|
|
||||||
],
|
|
||||||
)
|
|
|
@ -40,9 +40,9 @@ ng_package(
|
||||||
visibility = [
|
visibility = [
|
||||||
"//packages/bazel/test/ng_package:__pkg__",
|
"//packages/bazel/test/ng_package:__pkg__",
|
||||||
"//packages/compiler-cli/integrationtest:__pkg__",
|
"//packages/compiler-cli/integrationtest:__pkg__",
|
||||||
|
"//packages/compiler-cli/ngcc/test:__pkg__",
|
||||||
"//packages/compiler-cli/test:__pkg__",
|
"//packages/compiler-cli/test:__pkg__",
|
||||||
"//packages/compiler-cli/test/diagnostics:__pkg__",
|
"//packages/compiler-cli/test/diagnostics:__pkg__",
|
||||||
"//packages/compiler-cli/test/ngcc:__pkg__",
|
|
||||||
"//packages/compiler-cli/test/transformers:__pkg__",
|
"//packages/compiler-cli/test/transformers:__pkg__",
|
||||||
"//packages/compiler/test:__pkg__",
|
"//packages/compiler/test:__pkg__",
|
||||||
"//packages/language-service/test:__pkg__",
|
"//packages/language-service/test:__pkg__",
|
||||||
|
|
Loading…
Reference in New Issue