Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/design/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Note: There's a limit of 20 custom dimensions.
| 5 | `Flag: --style` | `string` |
| 6 | `--collection` | `string` |
| 7 | `--buildEventLog` | `boolean` |
| 8 | `Flag: --enableIvy` | `boolean` |
| 9 | `Flag: --inlineStyle` | `boolean` |
| 10 | `Flag: --inlineTemplate` | `boolean` |
| 11 | `Flag: --viewEncapsulation` | `string` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,8 @@
"files": [
"src/main.ts",
"src/polyfills.ts"
],<% if (!enableIvy) { %>
"include": [
"src/**/*.ts"
],
"exclude": [
"src/test.ts",
"src/**/*.spec.ts"
]<% } %><% if (enableIvy) { %>
"include": [
"src/**/*.d.ts"
],
"angularCompilerOptions": {
"enableIvy": true
}<% } %>
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]<% if (enableIvy) { %>,
"angularCompilerOptions": {
"enableIvy": true
}<% } %>
]
}
2 changes: 1 addition & 1 deletion packages/schematics/angular/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul
main: `${sourceRoot}/main.ts`,
polyfills: `${sourceRoot}/polyfills.ts`,
tsConfig: `${projectRoot}tsconfig.app.json`,
aot: !!options.enableIvy,
aot: true,
assets: [
`${sourceRoot}/favicon.ico`,
`${sourceRoot}/assets`,
Expand Down
39 changes: 0 additions & 39 deletions packages/schematics/angular/application/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,45 +213,6 @@ describe('Application Schematic', () => {
]));
});

it('should set AOT option to false for VE projects', async () => {
const options = { ...defaultOptions };

const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
.toPromise();
const workspace = JSON.parse(tree.readContent('/angular.json'));
expect(workspace.projects.foo.architect.build.options.aot).toEqual(false);
});

it('should set AOT option to true for Ivy projects', async () => {
const options = { ...defaultOptions, enableIvy: true };

const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
.toPromise();
const workspace = JSON.parse(tree.readContent('/angular.json'));
expect(workspace.projects.foo.architect.build.options.aot).toEqual(true);
});

it('should set the right files, exclude, include in the tsconfig for VE projects', async () => {
const tree = await schematicRunner.runSchematicAsync('application', defaultOptions, workspaceTree)
.toPromise();
const path = '/projects/foo/tsconfig.app.json';
const tsConfig = JSON.parse(tree.readContent(path));
expect(tsConfig.files).toEqual(['src/main.ts', 'src/polyfills.ts']);
expect(tsConfig.exclude).toEqual(['src/test.ts', 'src/**/*.spec.ts']);
expect(tsConfig.include).toEqual(['src/**/*.ts']);
});

it('should set the right files, exclude, include in the tsconfig for Ivy projects', async () => {
const options = { ...defaultOptions, enableIvy: true };
const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
.toPromise();
const path = '/projects/foo/tsconfig.app.json';
const tsConfig = JSON.parse(tree.readContent(path));
expect(tsConfig.files).toEqual(['src/main.ts', 'src/polyfills.ts']);
expect(tsConfig.exclude).toBeUndefined();
expect(tsConfig.include).toEqual(['src/**/*.d.ts']);
});

describe(`update package.json`, () => {
it(`should add build-angular to devDependencies`, async () => {
const tree = await schematicRunner.runSchematicAsync('application', defaultOptions, workspaceTree)
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
},
"x-prompt": "What name would you like to use for the application?"
},
"enableIvy": {
"description": "**EXPERIMENTAL** True to create a new app that uses the Ivy rendering engine.",
"type": "boolean",
"default": false,
"x-user-analytics": 8
},
"inlineStyle": {
"description": "When true, includes styles inline in the root component.ts file. Only CSS styles can be included inline. Default is false, meaning that an external styles file is created and referenced in the root component.ts file.",
"type": "boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the below options are not needed by ngtsc compiler, but we will leave them to make opt-out easier.

skipTemplateCodegen: true,
strictMetadataEmit: true,
enableResourceInlining: true,

"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
}
}
10 changes: 7 additions & 3 deletions packages/schematics/angular/library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function addDependenciesToPackageJson() {
};
}

function addAppToWorkspaceFile(
function addLibToWorkspaceFile(
options: LibraryOptions,
projectRoot: string,
projectName: string,
Expand All @@ -147,6 +147,11 @@ function addAppToWorkspaceFile(
tsConfig: `${projectRoot}/tsconfig.lib.json`,
project: `${projectRoot}/ng-package.json`,
},
configurations: {
production: {
tsConfig: `${projectRoot}/tsconfig.lib.prod.json`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need a migration for this, right?

Copy link
Collaborator Author

@alan-agius4 alan-agius4 Aug 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a separate PR for that, I made it separate since it can go in now in master. #15272

I also, created some utils, which would be needed for another schematic

},
},
},
test: {
builder: Builders.Karma,
Expand Down Expand Up @@ -199,7 +204,6 @@ export default function (options: LibraryOptions): Rule {
const folderName = `${scopeFolder}${strings.dasherize(options.name)}`;
const projectRoot = join(normalize(newProjectRoot), folderName);
const distRoot = `dist/${folderName}`;

const sourceDir = `${projectRoot}/src/lib`;

const templateSource = apply(url('./files'), [
Expand All @@ -219,7 +223,7 @@ export default function (options: LibraryOptions): Rule {

return chain([
mergeWith(templateSource),
addAppToWorkspaceFile(options, projectRoot, projectName),
addLibToWorkspaceFile(options, projectRoot, projectName),
options.skipPackageJson ? noop() : addDependenciesToPackageJson(),
options.skipTsConfig ? noop() : updateTsConfig(packageName, distRoot),
schematic('module', {
Expand Down
12 changes: 11 additions & 1 deletion packages/schematics/angular/library/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ describe('Library Schematic', () => {
'/projects/foo/package.json',
'/projects/foo/README.md',
'/projects/foo/tslint.json',
'/projects/foo/tsconfig.lib.json',
'/projects/foo/tsconfig.lib.prod.json',
'/projects/foo/src/test.ts',
'/projects/foo/src/my-index.ts',
'/projects/foo/src/lib/foo.module.ts',
Expand Down Expand Up @@ -132,7 +134,7 @@ describe('Library Schematic', () => {
});

it('should handle a pascalCasedName', async () => {
const options = {...defaultOptions, name: 'pascalCasedName'};
const options = { ...defaultOptions, name: 'pascalCasedName' };
const tree = await schematicRunner.runSchematicAsync('library', options, workspaceTree).toPromise();
const config = getJsonFileContent(tree, '/angular.json');
const project = config.projects.pascalCasedName;
Expand Down Expand Up @@ -317,4 +319,12 @@ describe('Library Schematic', () => {
const specTsConfig = JSON.parse(tree.readContent('/foo/tsconfig.spec.json'));
expect(specTsConfig.extends).toEqual('../tsconfig.json');
});

it(`should add 'production' configuration`, async () => {
const tree = await schematicRunner.runSchematicAsync('library', defaultOptions, workspaceTree)
.toPromise();

const workspace = JSON.parse(tree.readContent('/angular.json'));
expect(workspace.projects.foo.architect.build.configurations.production).toBeDefined();
});
});
1 change: 0 additions & 1 deletion packages/schematics/angular/ng-new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default function (options: NgNewOptions): Rule {
const applicationOptions: ApplicationOptions = {
projectRoot: '',
name: options.name,
enableIvy: options.enableIvy,
inlineStyle: options.inlineStyle,
inlineTemplate: options.inlineTemplate,
prefix: options.prefix,
Expand Down
5 changes: 0 additions & 5 deletions packages/schematics/angular/ng-new/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
},
"x-prompt": "What name would you like to use for the new workspace and initial project?"
},
"enableIvy": {
"description": "When true, creates a new app that uses the Ivy rendering engine.",
"type": "boolean",
"default": false
},
"skipInstall": {
"description": "When true, does not install dependency packages.",
"type": "boolean",
Expand Down
25 changes: 24 additions & 1 deletion packages/schematics/angular/web-worker/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ describe('Web Worker Schematic', () => {
});

it('should add exclusions to tsconfig.app.json', async () => {
const oldTsConfig = {
extends: '../../tsconfig.json',
include: [
'src/**/*.ts',
],
exclude: [
'src/test.ts',
'src/**/*.spec.ts',
],
};
appTree.overwrite('projects/bar/tsconfig.app.json', JSON.stringify(oldTsConfig, undefined, 2));

const tree = await schematicRunner.runSchematicAsync('web-worker', defaultOptions, appTree)
.toPromise();
const { exclude } = JSON.parse(tree.readContent('/projects/bar/tsconfig.app.json'));
Expand Down Expand Up @@ -120,7 +132,18 @@ describe('Web Worker Schematic', () => {
const tsConfigPath = '/projects/bar/src/tsconfig.app.json';
workspace.projects.bar.architect.build.options.tsConfig = tsConfigPath;
appTree.overwrite('/angular.json', JSON.stringify(workspace));
appTree.rename('projects/bar/tsconfig.app.json', tsConfigPath);

const oldTsConfig = {
extends: '../../../tsconfig.json',
include: [
'**/*.ts',
],
exclude: [
'test.ts',
'**/*.spec.ts',
],
};
appTree.create('projects/bar/src/tsconfig.app.json', JSON.stringify(oldTsConfig, undefined, 2));

const tree = await schematicRunner.runSchematicAsync('web-worker', defaultOptions, appTree)
.toPromise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
]
},
"angularCompilerOptions": {
"enableIvy": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@
],
"include": [
"**/*.d.ts"
],
"angularCompilerOptions": {
"enableIvy": true
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"main.server.ts"
],
"angularCompilerOptions": {
"entryModule": "app/app.server.module#AppServerModule",
"enableIvy": true
"entryModule": "app/app.server.module#AppServerModule"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@
"include": [
"**/*.spec.ts",
"**/*.d.ts"
],
"angularCompilerOptions": {
"enableIvy": true
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"es2017",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"es2017",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"es2017",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": false
}
}
17 changes: 12 additions & 5 deletions tests/legacy-cli/e2e/setup/500-create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getGlobalVariable } from '../utils/env';
import { expectFileToExist } from '../utils/fs';
import { gitClean } from '../utils/git';
import { ng } from '../utils/process';
import { prepareProjectForE2e } from '../utils/project';
import { prepareProjectForE2e, updateJsonFile } from '../utils/project';

export default async function() {
const argv = getGlobalVariable('argv');
Expand All @@ -18,13 +18,20 @@ export default async function() {
} else {
const extraArgs = [];

if (argv['ivy']) {
extraArgs.push('--enable-ivy');
}

await ng('new', 'test-project', '--skip-install', ...extraArgs);
await expectFileToExist(join(process.cwd(), 'test-project'));
process.chdir('./test-project');

if (!argv['ivy']) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we should flip this flag, so that we have to opt-in VE tests instead of opt-in Ivy ones.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I will do it later today or tmr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, let’s tackle this in a separate PR were we enable the full test suit for Ivy and remove —ivy and add —ve so that all tests will run in ivy mode by default.

await updateJsonFile('tsconfig.json', config => {
config.angularCompilerOptions.enableIvy = false;
});

// In VE non prod builds are non AOT by default
await updateJsonFile('angular.json', config => {
config.projects['test-project'].architect.build.options.aot = false;
});
}
}

await prepareProjectForE2e('test-project');
Expand Down
3 changes: 0 additions & 3 deletions tests/legacy-cli/e2e/tests/build/lazy-load-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ import { getGlobalVariable } from '../../utils/env';
import { appendToFile, prependToFile, readFile, replaceInFile, writeFile } from '../../utils/fs';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';

export default async function () {
const argv = getGlobalVariable('argv');
const ivyProject = argv['ivy'];
const projectName = 'test-project';
const appRoutingModulePath = 'src/app/app-routing.module.ts';

Expand Down
14 changes: 12 additions & 2 deletions tests/legacy-cli/e2e/tests/generate/library/library-consumption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { ng } from '../../../utils/process';

export default async function () {
await ng('generate', 'library', 'my-lib');
await ng('build', 'my-lib');

await writeFile('./src/app/app.module.ts', `
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
Expand Down Expand Up @@ -69,6 +67,18 @@ export default async function () {
});
`);

await runLibraryTests();
await runLibraryTests(true);
}

async function runLibraryTests(prodMode = false): Promise<void> {
const args = ['build', 'my-lib'];
if (prodMode) {
args.push('--prod');
}

await ng(...args);

// Check that the tests succeeds both with named project, unnammed (should test app), and prod.
await ng('e2e');
await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production');
Expand Down
Loading