Skip to content

Commit 0111693

Browse files
alan-agius4mgechev
authored andcommitted
Ivy build_ng_packagr (#15262)
* test: update ng-packagr builder tests to work on Windows * build: add ng packagr test large for ivy * test: fix web-worker test in ivy Previously, we were not testing web workers under Ivy as we were overriding tsconfig.app.json entirely without including enableIvy. When enabling Ivy we are getting warning of files that are part of the compilation which causing a warning to show and break the test. * build: update ng-packagr to `^5.4.0` * test: display ivy mode message once
1 parent 99ba5eb commit 0111693

File tree

25 files changed

+539
-50
lines changed

25 files changed

+539
-50
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ workflows:
350350
- test-large:
351351
name: test-large-ivy
352352
ivy: true
353-
glob: "packages/angular_devkit/build_angular/test/browser/*_spec_large.ts"
353+
glob: "packages/angular_devkit/@(build_angular|build_ng_packagr)/@(src|test)/@(build|browser)/*_spec_large.ts"
354354
requires:
355355
- build
356356
- e2e-cli:

packages/angular_devkit/build_angular/test/browser/web-worker_spec_large.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ describe('Browser Builder Web Worker support', () => {
7777
"outDir": "../out-tsc/worker",
7878
"types": []
7979
},
80-
"exclude": [
81-
"test.ts",
82-
"**/*.spec.ts",
83-
"**/*.worker.ts",
84-
"app/dep.ts",
80+
"files": [
81+
"main.ts",
82+
"polyfills.ts"
8583
]
8684
}`,
8785
};

packages/angular_devkit/build_angular/test/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ import {
2121
import { BrowserBuilderOutput } from '../src/browser';
2222

2323
export const ivyEnabled = process.argv.includes('--ivy');
24-
if (ivyEnabled) {
25-
// tslint:disable-next-line:no-console
26-
console.warn('********* IVY Enabled ***********');
27-
}
2824

2925
const devkitRoot = normalize((global as any)._DevKitRoot); // tslint:disable-line:no-any
3026
export const workspaceRoot = join(

packages/angular_devkit/build_ng_packagr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@angular/compiler": "~8.2.0-rc.0",
1818
"@angular/compiler-cli": "~8.2.0-rc.0",
1919
"@angular-devkit/core": "0.0.0",
20-
"ng-packagr": "^5.3.0",
20+
"ng-packagr": "^5.4.0",
2121
"tslib": "^1.10.0"
2222
}
2323
}

packages/angular_devkit/build_ng_packagr/src/build/index_spec_large.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@ import { Architect } from '@angular-devkit/architect';
99
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
1010
import { TestProjectHost, TestingArchitectHost } from '@angular-devkit/architect/testing';
1111
import {
12+
experimental,
13+
getSystemPath,
1214
join,
1315
normalize,
1416
schema,
1517
virtualFs,
16-
workspaces,
1718
} from '@angular-devkit/core'; // tslint:disable-line:no-implicit-dependencies
1819
import { map, take, tap } from 'rxjs/operators';
1920

21+
const ivyEnabled = process.argv.includes('--ivy');
22+
2023
const devkitRoot = (global as unknown as { _DevKitRoot: string})._DevKitRoot;
2124
const workspaceRoot = join(
2225
normalize(devkitRoot),
23-
'tests/angular_devkit/build_ng_packagr/ng-packaged/',
26+
`tests/angular_devkit/build_ng_packagr/ng-packaged${ivyEnabled ? '-ivy' : ''}/`,
2427
);
2528

2629
describe('NgPackagr Builder', () => {
@@ -33,15 +36,14 @@ describe('NgPackagr Builder', () => {
3336
const registry = new schema.CoreSchemaRegistry();
3437
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
3538

36-
const { workspace } = await workspaces.readWorkspace(
37-
host.root(),
38-
workspaces.createWorkspaceHost(host),
39-
);
39+
const workspaceSysPath = getSystemPath(host.root());
40+
const workspace = await experimental.workspace.Workspace.fromPath(host, host.root(), registry);
4041
const architectHost = new TestingArchitectHost(
41-
host.root(),
42-
host.root(),
43-
new WorkspaceNodeModulesArchitectHost(workspace, host.root()),
42+
workspaceSysPath,
43+
workspaceSysPath,
44+
new WorkspaceNodeModulesArchitectHost(workspace, workspaceSysPath),
4445
);
46+
4547
architect = new Architect(architectHost, registry);
4648
});
4749

@@ -59,6 +61,12 @@ describe('NgPackagr Builder', () => {
5961
host.scopedSync().read(normalize('./dist/lib/fesm5/lib.js')),
6062
);
6163
expect(content).toContain('lib works');
64+
65+
if (ivyEnabled) {
66+
expect(content).toContain('ngComponentDef');
67+
} else {
68+
expect(content).not.toContain('ngComponentDef');
69+
}
6270
});
6371

6472
it('rebuilds on TS file changes', async () => {

packages/schematics/angular/utility/latest-versions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ export const latestVersions = {
2121
AngularPWA: '~0.803.0-next.1',
2222

2323
tsickle: '^0.36.0',
24-
ngPackagr: '^5.3.0',
24+
ngPackagr: '^5.4.0',
2525
};

scripts/test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ export default function(args: ParsedArgs, logger: logging.Logger) {
8989
const specGlob = args.large ? '*_spec_large.ts' : '*_spec.ts';
9090
const regex = args.glob ? args.glob : `packages/**/${specGlob}`;
9191

92+
if (args['ivy']) {
93+
// tslint:disable-next-line:no-console
94+
console.warn('********* IVY Enabled ***********');
95+
}
96+
9297
if (args.large) {
9398
// Default timeout for large specs is 2.5 minutes.
9499
jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
8+
# dependencies
9+
/node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
testem.log
34+
/typings
35+
36+
# e2e
37+
/e2e/*.js
38+
/e2e/*.map
39+
40+
# System Files
41+
.DS_Store
42+
Thumbs.db
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "../../../../packages/angular_devkit/core/src/workspace/workspace-schema.json",
3+
"version": 1,
4+
"projects": {
5+
"lib": {
6+
"root": "projects/lib",
7+
"projectType": "library",
8+
"targets": {
9+
"build": {
10+
"builder": "../../../../packages/angular_devkit/build_ng_packagr:build",
11+
"options": {
12+
"project": "projects/lib/ng-package.json",
13+
"tsConfig": "projects/lib/tsconfig.lib.json"
14+
},
15+
"configurations": {
16+
"production": {
17+
"tsConfig": "projects/lib/tsconfig.lib.prod.json"
18+
}
19+
}
20+
},
21+
"test": {
22+
"builder": "../../../../packages/angular_devkit/build_angular:karma",
23+
"options": {
24+
"main": "projects/lib/src/test.ts",
25+
"tsConfig": "projects/lib/tsconfig.spec.json",
26+
"karmaConfig": "projects/lib/karma.conf.js",
27+
"browsers": "ChromeHeadlessCI",
28+
"progress": false,
29+
"watch": false
30+
}
31+
},
32+
"lint": {
33+
"builder": "../../../../packages/angular_devkit/build_angular:tslint",
34+
"options": {
35+
"tsConfig": [
36+
"projects/lib/tsconfig.lib.json",
37+
"projects/lib/tsconfig.spec.json"
38+
],
39+
"exclude": [
40+
"**/node_modules/**"
41+
]
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
// Karma configuration file, see link for more information
9+
// https://karma-runner.github.io/1.0/config/configuration-file.html
10+
11+
module.exports = function (config) {
12+
config.set({
13+
basePath: '',
14+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
15+
plugins: [
16+
require('karma-jasmine'),
17+
require('karma-chrome-launcher'),
18+
require('karma-jasmine-html-reporter'),
19+
require('karma-coverage-istanbul-reporter'),
20+
require('@angular-devkit/build-angular/plugins/karma')
21+
],
22+
client: {
23+
clearContext: false // leave Jasmine Spec Runner output visible in browser
24+
},
25+
coverageIstanbulReporter: {
26+
dir: require('path').join(__dirname, 'coverage'),
27+
reports: ['html', 'lcovonly'],
28+
fixWebpackSourcePaths: true
29+
},
30+
reporters: ['progress', 'kjhtml'],
31+
port: 9876,
32+
colors: true,
33+
logLevel: config.LOG_INFO,
34+
autoWatch: true,
35+
browsers: ['Chrome'],
36+
customLaunchers: {
37+
ChromeHeadlessCI: {
38+
base: 'ChromeHeadless',
39+
flags: ['--disable-gpu']
40+
}
41+
},
42+
singleRun: false
43+
});
44+
};

0 commit comments

Comments
 (0)