Skip to content

Commit

Permalink
refactor(compiler-cli): use the transformer based compiler by default
Browse files Browse the repository at this point in the history
The source map does not currently work with the transformer pipeline.
It will be re-enabled after TypeScript 2.4 is made the min version.

To revert to the former compiler, use the `disableTransformerPipeline` in
tsconfig.json:

```
{
  "angularCompilerOptions": {
    "disableTransformerPipeline": true
  }
}
```
  • Loading branch information
vicb committed Aug 10, 2017
1 parent cea0241 commit 834c1ee
Show file tree
Hide file tree
Showing 31 changed files with 567 additions and 247 deletions.
2 changes: 1 addition & 1 deletion integration/hello_world__closure/package.json
Expand Up @@ -13,7 +13,7 @@
"@angular/tsc-wrapped": "file:../../dist/packages-dist/tsc-wrapped",
"google-closure-compiler": "20170409.0.0",
"rxjs": "5.3.1",
"typescript": "2.1.6",
"typescript": "~2.3.1",
"zone.js": "0.8.6"
},
"devDependencies": {
Expand Down
30 changes: 30 additions & 0 deletions integration/i18n/closure.conf
@@ -0,0 +1,30 @@
--compilation_level=ADVANCED_OPTIMIZATIONS
--language_out=ES5
--js_output_file=dist/bundle.js
--output_manifest=dist/manifest.MF
--variable_renaming_report=dist/variable_renaming_report
--property_renaming_report=dist/property_renaming_report
--create_source_map=%outname%.map

--warning_level=QUIET
--dependency_mode=STRICT
--rewrite_polyfills=false

node_modules/zone.js/dist/zone_externs.js

--js node_modules/rxjs/**.js
--process_common_js_modules
--module_resolution=node

node_modules/@angular/core/@angular/core.js
--js_module_root=node_modules/@angular/core
node_modules/@angular/core/src/testability/testability.externs.js

node_modules/@angular/common/@angular/common.js
--js_module_root=node_modules/@angular/common

node_modules/@angular/platform-browser/@angular/platform-browser.js
--js_module_root=node_modules/@angular/platform-browser

--js built/**.js
--entry_point=built/src/main
10 changes: 10 additions & 0 deletions integration/i18n/e2e/app.e2e-spec.ts
@@ -0,0 +1,10 @@
import { browser, element, by } from 'protractor';

describe('i18n E2E Tests', function () {
it('remove i18n attributes', function () {
browser.get('');
const div = element(by.css('div'));
expect(div.getAttribute('title')).not.toBe(null);
expect(div.getAttribute('i18n')).toBe(null);
});
});
15 changes: 15 additions & 0 deletions integration/i18n/e2e/browser.config.json
@@ -0,0 +1,15 @@
{
"open": false,
"logLevel": "silent",
"port": 8080,
"server": {
"baseDir": "src",
"routes": {
"/dist": "dist",
"/node_modules": "node_modules"
},
"middleware": {
"0": null
}
}
}
16 changes: 16 additions & 0 deletions integration/i18n/e2e/protractor.config.js
@@ -0,0 +1,16 @@
exports.config = {
specs: [
'../built/e2e/*.e2e-spec.js'
],
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox'],
binary: process.env.CHROME_BIN,
}
},
directConnect: true,
baseUrl: 'http://localhost:8080/',
framework: 'jasmine',
useAllAngular2AppRoots: true
};
8 changes: 8 additions & 0 deletions integration/i18n/e2e/tsconfig.json
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"outDir": "../built/e2e",
"types": ["jasmine"],
// TODO(alexeagle): was required for Protractor 4.0.11
"skipLibCheck": true
}
}
32 changes: 32 additions & 0 deletions integration/i18n/package.json
@@ -0,0 +1,32 @@
{
"name": "angular-integration",
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"@angular/animations": "file:../../dist/packages-dist/animations",
"@angular/common": "file:../../dist/packages-dist/common",
"@angular/compiler": "file:../../dist/packages-dist/compiler",
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@angular/core": "file:../../dist/packages-dist/core",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"@angular/tsc-wrapped": "file:../../dist/packages-dist/tsc-wrapped",
"google-closure-compiler": "20170409.0.0",
"rxjs": "5.3.1",
"typescript": "~2.3.1",
"zone.js": "0.8.6"
},
"devDependencies": {
"@types/jasmine": "2.5.41",
"concurrently": "3.4.0",
"lite-server": "2.2.2",
"protractor": "file:../../node_modules/protractor"
},
"scripts": {
"closure": "java -jar node_modules/google-closure-compiler/compiler.jar --flagfile closure.conf",
"test": "ngc && yarn run closure && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first",
"serve": "lite-server -c e2e/browser.config.json",
"preprotractor": "tsc -p e2e",
"protractor": "protractor e2e/protractor.config.js"
}
}
11 changes: 11 additions & 0 deletions integration/i18n/src/app.ts
@@ -0,0 +1,11 @@
import {HelloWorldComponent} from './hello-world.component';

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';

@NgModule({
declarations: [HelloWorldComponent],
bootstrap: [HelloWorldComponent],
imports: [BrowserModule],
})
export class AppModule {}
9 changes: 9 additions & 0 deletions integration/i18n/src/hello-world.component.ts
@@ -0,0 +1,9 @@
import {Component} from '@angular/core';

@Component({
selector: 'hello-world-app',
template: `<div i18n="desc|meaning" title="i18n attribute should be removed">Hello {{ name }}!</div>`,
})
export class HelloWorldComponent {
name: string = 'world';
}
18 changes: 18 additions & 0 deletions integration/i18n/src/index.html
@@ -0,0 +1,18 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Hello World</title>
<base href="/">
</head>

<body>
<hello-world-app>Loading...</hello-world-app>

<script src="node_modules/zone.js/dist/zone.min.js"></script>
<script src="dist/bundle.js"></script>

</body>

</html>
4 changes: 4 additions & 0 deletions integration/i18n/src/main.ts
@@ -0,0 +1,4 @@
import {platformBrowser} from '@angular/platform-browser';
import {AppModuleNgFactory} from './app.ngfactory';

platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
30 changes: 30 additions & 0 deletions integration/i18n/tsconfig.json
@@ -0,0 +1,30 @@
{
"angularCompilerOptions": {
"annotationsAs": "static fields",
"annotateForClosureCompiler": true,
"alwaysCompileGeneratedCode": true
},

"compilerOptions": {
"module": "es2015",
"moduleResolution": "node",
// TODO(i): strictNullChecks should turned on but are temporarily disabled due to #15432
"strictNullChecks": false,
"target": "es6",
"noImplicitAny": false,
"sourceMap": false,
"experimentalDecorators": true,
"outDir": "built",
"rootDir": ".",
"declaration": true,
"types": []
},

"exclude": [
"vendor",
"node_modules",
"built",
"dist",
"e2e"
]
}
12 changes: 0 additions & 12 deletions packages/compiler-cli/integrationtest/alt/src/bootstrap.ts

This file was deleted.

11 changes: 2 additions & 9 deletions packages/compiler-cli/integrationtest/test/basic_spec.ts
Expand Up @@ -12,7 +12,6 @@ import * as path from 'path';
import {MultipleComponentsMyComp} from '../src/a/multiple_components';
import {BasicComp} from '../src/basic';
import {createComponent} from './util';
import {createComponentAlt} from './util_alt';

describe('template codegen output', () => {
const outDir = 'src';
Expand All @@ -37,9 +36,9 @@ describe('template codegen output', () => {
expect(fs.readFileSync(dtsOutput, {encoding: 'utf-8'})).toContain('Basic');
});

it('should write .ngfactory.ts for .d.ts inputs', () => {
it('should write .ngfactory.js for .d.ts inputs', () => {
const factoryOutput =
path.join('node_modules', '@angular2-material', 'button', 'button.ngfactory.ts');
path.join('node_modules', '@angular2-material', 'button', 'button.ngfactory.js');
expect(fs.existsSync(factoryOutput)).toBeTruthy();
});

Expand Down Expand Up @@ -95,11 +94,5 @@ describe('template codegen output', () => {
expect(containerElement.attributes['title']).toBe('käännä teksti');
expect(containerElement.attributes['i18n-title']).toBeUndefined();
});

it('should have removed i18n markup event without translations', () => {
const containerElement = createComponentAlt(BasicComp).debugElement.children[0];
expect(containerElement.attributes['title']).toBe('translate me');
expect(containerElement.attributes['i18n-title']).toBeUndefined();
});
});
});
Expand Up @@ -10,7 +10,8 @@ import './init';
import {BindingErrorComp} from '../src/errors';
import {createComponent} from './util';

describe('source maps', () => {
// TODO(tbosch): source maps does not currently work with the transformer pipeline
xdescribe('source maps', () => {
it('should report source location for binding errors', () => {
const comp = createComponent(BindingErrorComp);
let error: any;
Expand Down
33 changes: 0 additions & 33 deletions packages/compiler-cli/integrationtest/test/util_alt.ts

This file was deleted.

32 changes: 0 additions & 32 deletions packages/compiler-cli/integrationtest/tsconfig-build-alt.json

This file was deleted.

4 changes: 3 additions & 1 deletion packages/compiler-cli/integrationtest/tsconfig-build.json
Expand Up @@ -5,7 +5,9 @@
"genDir": ".",
"debug": true,
"enableSummariesForJit": true,
"alwaysCompileGeneratedCode": true
"alwaysCompileGeneratedCode": true,
"locale": "fi",
"i18nFormat": "xlf"
},

"compilerOptions": {
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-cli/package.json
Expand Up @@ -11,7 +11,8 @@
"dependencies": {
"@angular/tsc-wrapped": "5.0.0-beta.3",
"reflect-metadata": "^0.1.2",
"minimist": "^1.2.0"
"minimist": "^1.2.0",
"tsickle": "^0.23.4"
},
"peerDependencies": {
"typescript": "^2.0.2",
Expand Down
Expand Up @@ -56,7 +56,7 @@ function getReferences(info: DiagnosticTemplateInfo): SymbolDeclaration[] {
name: reference.name,
kind: 'reference',
type: type || info.query.getBuiltinType(BuiltinType.Any),
get definition() { return getDefintionOf(info, reference); }
get definition() { return getDefinitionOf(info, reference); }
});
}
}
Expand All @@ -77,7 +77,7 @@ function getReferences(info: DiagnosticTemplateInfo): SymbolDeclaration[] {
return result;
}

function getDefintionOf(info: DiagnosticTemplateInfo, ast: TemplateAst): Definition|undefined {
function getDefinitionOf(info: DiagnosticTemplateInfo, ast: TemplateAst): Definition|undefined {
if (info.fileName) {
const templateOffset = info.offset;
return [{
Expand Down Expand Up @@ -124,7 +124,7 @@ function getVarDeclarations(
}
result.push({
name,
kind: 'variable', type, get definition() { return getDefintionOf(info, variable); }
kind: 'variable', type, get definition() { return getDefinitionOf(info, variable); }
});
}
}
Expand Down

0 comments on commit 834c1ee

Please sign in to comment.