refactor(compiler_cli): move it into modules/@angular and integrate properly into the build
This also does no more depend on a version on npm for the compiler_cli. Also runs the tests for tools/metadata
This commit is contained in:
@ -0,0 +1 @@
|
||||
<div></div>
|
@ -0,0 +1,21 @@
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
template: '<div></div>',
|
||||
})
|
||||
export class MyComp {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'next-comp',
|
||||
templateUrl: './multiple_components.html',
|
||||
})
|
||||
export class NextComp {
|
||||
}
|
||||
|
||||
// Verify that exceptions from DirectiveResolver don't propagate
|
||||
export function NotADirective(c: any): void {}
|
||||
@NotADirective
|
||||
export class HasCustomDecorator {
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
@import './shared.css';
|
||||
|
||||
.green { color: green }
|
@ -0,0 +1,3 @@
|
||||
<div>{{ctxProp}}</div>
|
||||
<form><input type="button" [(ngModel)]="ctxProp"/></form>
|
||||
<my-comp></my-comp>
|
15
modules/@angular/compiler_cli/integrationtest/src/basic.ts
Normal file
15
modules/@angular/compiler_cli/integrationtest/src/basic.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {Component, Inject} from '@angular/core';
|
||||
import {FORM_DIRECTIVES} from '@angular/common';
|
||||
import {MyComp} from './a/multiple_components';
|
||||
|
||||
@Component({
|
||||
selector: 'basic',
|
||||
templateUrl: './basic.html',
|
||||
styles: ['.red { color: red }'],
|
||||
styleUrls: ['./basic.css'],
|
||||
directives: [MyComp, FORM_DIRECTIVES]
|
||||
})
|
||||
export class Basic {
|
||||
ctxProp: string;
|
||||
constructor() { this.ctxProp = 'initiaValue'; }
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
import {coreBootstrap, ReflectiveInjector} from '@angular/core';
|
||||
import {browserPlatform, BROWSER_APP_STATIC_PROVIDERS} from '@angular/platform-browser';
|
||||
import {BasicNgFactory} from './basic.ngfactory';
|
||||
import {Basic} from './basic';
|
||||
|
||||
const appInjector =
|
||||
ReflectiveInjector.resolveAndCreate(BROWSER_APP_STATIC_PROVIDERS, browserPlatform().injector);
|
||||
coreBootstrap(appInjector, BasicNgFactory);
|
2
modules/@angular/compiler_cli/integrationtest/src/dep.d.ts
vendored
Normal file
2
modules/@angular/compiler_cli/integrationtest/src/dep.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// Verify we don't try to extract metadata for .d.ts files
|
||||
export declare var a: string;
|
@ -0,0 +1,29 @@
|
||||
import {Component, Inject, OpaqueToken} from '@angular/core';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
export const SOME_OPAQUE_TOKEN = new OpaqueToken('opaqueToken');
|
||||
|
||||
@Component({
|
||||
selector: 'comp-providers',
|
||||
template: '',
|
||||
providers: [
|
||||
{provide: 'strToken', useValue: 'strValue'},
|
||||
{provide: SOME_OPAQUE_TOKEN, useValue: 10},
|
||||
{provide: 'reference', useValue: NgIf},
|
||||
{provide: 'complexToken', useValue: {a: 1, b: ['test', SOME_OPAQUE_TOKEN]}},
|
||||
]
|
||||
})
|
||||
export class CompWithProviders {
|
||||
constructor(@Inject('strToken') public ctxProp) {}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'cmp-reference',
|
||||
template: `
|
||||
<input #a>{{a.value}}
|
||||
<div *ngIf="true">{{a.value}}</div>
|
||||
`,
|
||||
directives: [NgIf]
|
||||
})
|
||||
export class CompWithReferences {
|
||||
}
|
@ -0,0 +1 @@
|
||||
.blue { color: blue }
|
@ -0,0 +1,26 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
describe("template codegen output", () => {
|
||||
const outDir = path.join('dist', 'all', '@angular', 'compiler_cli', 'integrationtest', 'src');
|
||||
|
||||
it("should lower Decorators without reflect-metadata", () => {
|
||||
const jsOutput = path.join(outDir, 'basic.js');
|
||||
expect(fs.existsSync(jsOutput)).toBeTruthy();
|
||||
expect(fs.readFileSync(jsOutput, {encoding: 'utf-8'})).not.toContain('Reflect.decorate');
|
||||
});
|
||||
|
||||
it("should produce metadata.json outputs", () => {
|
||||
const metadataOutput = path.join(outDir, 'basic.metadata.json');
|
||||
expect(fs.existsSync(metadataOutput)).toBeTruthy();
|
||||
const output = fs.readFileSync(metadataOutput, {encoding: 'utf-8'});
|
||||
expect(output).toContain('"decorators":');
|
||||
expect(output).toContain('"name":"Component","module":"@angular/core"');
|
||||
});
|
||||
|
||||
it("should write .d.ts files", () => {
|
||||
const dtsOutput = path.join(outDir, 'basic.d.ts');
|
||||
expect(fs.existsSync(dtsOutput)).toBeTruthy();
|
||||
expect(fs.readFileSync(dtsOutput, {encoding: 'utf-8'})).toContain('Basic');
|
||||
});
|
||||
});
|
23
modules/@angular/compiler_cli/integrationtest/tsconfig.json
Normal file
23
modules/@angular/compiler_cli/integrationtest/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"angularCompilerOptions": {
|
||||
// For TypeScript 1.8, we have to lay out generated files
|
||||
// in the same source directory with your code.
|
||||
"genDir": ".",
|
||||
"legacyPackageLayout": false
|
||||
},
|
||||
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitAny": false,
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../../../../dist/all/@angular/compiler_cli/integrationtest",
|
||||
"rootDir": "",
|
||||
"declaration": true,
|
||||
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@angular/*": ["../../../../dist/all/@angular/*"]
|
||||
}
|
||||
}
|
||||
}
|
4
modules/@angular/compiler_cli/integrationtest/typings.d.ts
vendored
Normal file
4
modules/@angular/compiler_cli/integrationtest/typings.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/// <reference path="../../typings/es6-collections/es6-collections.d.ts" />
|
||||
/// <reference path="../../typings/es6-promise/es6-promise.d.ts" />
|
||||
/// <reference path="../../typings/node/node.d.ts" />
|
||||
/// <reference path="../../typings/jasmine/jasmine.d.ts" />
|
Reference in New Issue
Block a user