Skip to content

Commit 3886aab

Browse files
committed
feat(@schematics/angular): add a --experimental-ivy flag to ng-new
This will create a new Ivy-enabled application. Also available in "ng g application".
1 parent 569acc4 commit 3886aab

File tree

13 files changed

+100
-27
lines changed

13 files changed

+100
-27
lines changed

packages/schematics/angular/application/files/root/tsconfig.app.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"exclude": [
88
"src/test.ts",
99
"**/*.spec.ts"
10-
]
10+
]<% if (experimentalIvy) { %>,
11+
"angularCompilerOptions": {
12+
"enableIvy": "ngtsc"
13+
}<% } %>
1114
}
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { enableProdMode } from '@angular/core';
2-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1+
<%= experimentalIvy ? '// ' : '' %>import { enableProdMode } from '@angular/core';
2+
<%= experimentalIvy ? '// ' : '' %>import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3+
<%= experimentalIvy ? '// ' : '' %>
4+
<%= experimentalIvy ? '// ' : '' %>import { AppModule } from './app/app.module';
5+
<%= experimentalIvy ? '// ' : '' %>import { environment } from './environments/environment';
6+
<%= experimentalIvy ? '// ' : '' %>
7+
<%= experimentalIvy ? '// ' : '' %>if (environment.production) {
8+
<%= experimentalIvy ? '// ' : '' %> enableProdMode();
9+
<%= experimentalIvy ? '// ' : '' %>}
10+
<%= experimentalIvy ? '// ' : '' %>
11+
<%= experimentalIvy ? '// ' : '' %>platformBrowserDynamic().bootstrapModule(AppModule)
12+
<%= experimentalIvy ? '// ' : '' %> .catch(err => console.log(err));
13+
<% if (experimentalIvy) { %>
14+
import { AppComponent } from './app/app.component';
15+
import { ɵrenderComponent as renderComponent } from '@angular/core';
316

4-
import { AppModule } from './app/app.module';
5-
import { environment } from './environments/environment';
6-
7-
if (environment.production) {
8-
enableProdMode();
9-
}
10-
11-
platformBrowserDynamic().bootstrapModule(AppModule)
12-
.catch(err => console.log(err));
17+
renderComponent(AppComponent);
18+
<% } %>

packages/schematics/angular/application/other-files/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { AppComponent } from './app.component';
88
declarations: [
99
AppComponent
1010
],
11-
imports: [
11+
imports: [<% if (!experimentalIvy) { %>
1212
BrowserModule<% if (routing) { %>,
1313
AppRoutingModule<% } %>
14-
],
14+
<% } %>],
1515
providers: [],
1616
bootstrap: [AppComponent]
1717
})

packages/schematics/angular/application/schema.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export interface Schema {
1515
* The name of the application.
1616
*/
1717
name: string;
18+
/**
19+
* EXPERIMENTAL: Specifies whether to create a new application which uses the Ivy rendering
20+
* engine.
21+
*/
22+
experimentalIvy?: boolean;
1823
/**
1924
* Specifies if the style will be in the ts file.
2025
*/

packages/schematics/angular/application/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
"index": 0
1818
}
1919
},
20+
"experimentalIvy": {
21+
"description": "EXPERIMENTAL: Specifies whether to create a new application which uses the Ivy rendering engine.",
22+
"type": "boolean",
23+
"default": false
24+
},
2025
"inlineStyle": {
2126
"description": "Specifies if the style will be in the ts file.",
2227
"type": "boolean",

packages/schematics/angular/ng-new/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ export default function (options: NgNewOptions): Rule {
3939
const workspaceOptions: WorkspaceOptions = {
4040
name: options.name,
4141
version: options.version,
42+
experimentalAngularNext: options.experimentalIvy,
4243
newProjectRoot: options.newProjectRoot || 'projects',
4344
};
4445
const applicationOptions: ApplicationOptions = {
4546
projectRoot: '',
4647
name: options.name,
48+
experimentalIvy: options.experimentalIvy,
4749
inlineStyle: options.inlineStyle,
4850
inlineTemplate: options.inlineTemplate,
4951
prefix: options.prefix,

packages/schematics/angular/ng-new/schema.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export interface Schema {
1515
* The name of the workspace.
1616
*/
1717
name: string;
18+
/**
19+
* EXPERIMENTAL: Specifies whether to create a new application which uses the Ivy rendering
20+
* engine.
21+
*/
22+
experimentalIvy?: boolean;
1823
/**
1924
* Skip installing dependency packages.
2025
*/

packages/schematics/angular/ng-new/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
"index": 0
1818
}
1919
},
20+
"experimentalIvy": {
21+
"description": "EXPERIMENTAL: Specifies whether to create a new application which uses the Ivy rendering engine.",
22+
"type": "boolean",
23+
"default": false
24+
},
2025
"skipInstall": {
2126
"description": "Skip installing dependency packages.",
2227
"type": "boolean",

packages/schematics/angular/workspace/files/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111
},
1212
"private": true,
1313
"dependencies": {
14-
"@angular/animations": "<%= latestVersions.Angular %>",
15-
"@angular/common": "<%= latestVersions.Angular %>",
16-
"@angular/compiler": "<%= latestVersions.Angular %>",
17-
"@angular/core": "<%= latestVersions.Angular %>",
18-
"@angular/forms": "<%= latestVersions.Angular %>",
19-
"@angular/http": "<%= latestVersions.Angular %>",
20-
"@angular/platform-browser": "<%= latestVersions.Angular %>",
21-
"@angular/platform-browser-dynamic": "<%= latestVersions.Angular %>",
22-
"@angular/router": "<%= latestVersions.Angular %>",
14+
"@angular/animations": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
15+
"@angular/common": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
16+
"@angular/compiler": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
17+
"@angular/core": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
18+
"@angular/forms": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
19+
"@angular/http": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
20+
"@angular/platform-browser": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
21+
"@angular/platform-browser-dynamic": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
22+
"@angular/router": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
2323
"core-js": "^2.5.4",
2424
"rxjs": "<%= latestVersions.RxJs %>",
2525
"zone.js": "<%= latestVersions.ZoneJs %>"
2626
},
2727
"devDependencies": {
28-
"@angular/cli": "~<%= version %>",
29-
"@angular/compiler-cli": "<%= latestVersions.Angular %>",
30-
"@angular/language-service": "<%= latestVersions.Angular %>",
28+
"@angular/cli": "<%= experimentalAngularNext ? 'next' : '~' + version %>",
29+
"@angular/compiler-cli": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
30+
"@angular/language-service": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
3131
"@types/jasmine": "~2.8.8",
3232
"@types/jasminewd2": "~2.0.3",
3333
"@types/node": "~8.9.4",

packages/schematics/angular/workspace/schema.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export interface Schema {
1111
* The name of the workspace.
1212
*/
1313
name: string;
14+
/**
15+
* Uses the next version of Angular.
16+
*/
17+
experimentalAngularNext?: boolean;
1418
/**
1519
* The path where new projects will be created.
1620
*/

0 commit comments

Comments
 (0)