-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@schematics/angular): configure new libraries to be published in…
… Ivy partial mode With this change we configure new libraries to be published using Ivy partial compilation instead of the deprecated View Engine rendering engine, we also remove several view engine specific `angularCompilerOptions`. New libraries can be published using this format, as they are not depend upon by View Engine libraries or application.
- Loading branch information
1 parent
de63f41
commit 695a01b
Showing
9 changed files
with
119 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
"declarationMap": false | ||
}, | ||
"angularCompilerOptions": { | ||
"enableIvy": false | ||
"compilationMode": "partial" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ | |
"declarationMap": false | ||
}, | ||
"angularCompilerOptions": { | ||
"enableIvy": false | ||
"compilationMode": "partial" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
tests/legacy-cli/e2e/tests/generate/library/library-basic.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
tests/legacy-cli/e2e/tests/generate/library/library-consumption-ivy-partial.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { writeFile } from '../../../utils/fs'; | ||
import { ng } from '../../../utils/process'; | ||
import { updateJsonFile } from '../../../utils/project'; | ||
|
||
export default async function () { | ||
await ng('generate', 'library', 'my-lib'); | ||
|
||
await writeFile('./src/app/app.module.ts', ` | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { NgModule } from '@angular/core'; | ||
import { MyLibModule } from 'my-lib'; | ||
import { AppComponent } from './app.component'; | ||
@NgModule({ | ||
declarations: [ | ||
AppComponent | ||
], | ||
imports: [ | ||
BrowserModule, | ||
MyLibModule, | ||
], | ||
providers: [], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule { } | ||
`); | ||
|
||
await writeFile('./src/app/app.component.ts', ` | ||
import { Component } from '@angular/core'; | ||
import { MyLibService } from 'my-lib'; | ||
@Component({ | ||
selector: 'app-root', | ||
template: '<lib-my-lib></lib-my-lib>' | ||
}) | ||
export class AppComponent { | ||
title = 'test-project'; | ||
constructor(myLibService: MyLibService) { | ||
console.log(myLibService); | ||
} | ||
} | ||
`); | ||
|
||
await writeFile('e2e/src/app.e2e-spec.ts', ` | ||
import { browser, logging, element, by } from 'protractor'; | ||
import { AppPage } from './app.po'; | ||
describe('workspace-project App', () => { | ||
let page: AppPage; | ||
beforeEach(() => { | ||
page = new AppPage(); | ||
}); | ||
it('should display text from library component', async () => { | ||
await page.navigateTo(); | ||
expect(await element(by.css('lib-my-lib p')).getText()).toEqual('my-lib works!'); | ||
}); | ||
afterEach(async () => { | ||
// Assert that there are no errors emitted from the browser | ||
const logs = await browser.manage().logs().get(logging.Type.BROWSER); | ||
expect(logs).not.toContain(jasmine.objectContaining({ | ||
level: logging.Level.SEVERE, | ||
})); | ||
}); | ||
}); | ||
`); | ||
|
||
// Build library in partial mode (production) | ||
await ng('build', 'my-lib', '--configuration=production'); | ||
|
||
// AOT linking | ||
await runTests(); | ||
|
||
// JIT linking | ||
await updateJsonFile('angular.json', config => { | ||
const build = config.projects['test-project'].architect.build; | ||
build.options.aot = false; | ||
build.configurations.production.buildOptimizer = false; | ||
}); | ||
|
||
await runTests(); | ||
} | ||
|
||
async function runTests(): Promise<void> { | ||
// Check that the tests succeeds both with named project, unnamed (should test app), and prod. | ||
await ng('e2e'); | ||
await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters