Skip to content

Commit 18c0825

Browse files
Migrate to Angular 15 and enable ivy (#2212)
This commit migrates the angular packages to Angular ^15. Support for older Angular versions is dropped. Support for newer Angular versions than 15 is not added with this commit. This gets rid of using Webpack for Angular builds. Only rollup is used there now. To achieve this without adding an Angular workspace at the repository root, a custom test runner was implemented. Relax the Angular package's ESLint configs to not show import/no-unresolved errors for the Angular packages due to a bug in the eslint import plugin: import-js/eslint-plugin-import#1810 Misc CI change: Adapted the coverage report merge to prepend paths. This improves and fixes the coverage report because coveralls can recognize the files from the merged report. Co-authored-by: Lucas Koehler <lkoehler@eclipsesource.com>
1 parent da3321b commit 18c0825

37 files changed

+7516
-3625
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ stats.html
1313
!.vscode/settings.json
1414

1515
.coveralls.yml
16-
packages/examples-react/build
16+
packages/examples-react/build
17+
18+
**/.angular/cache

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "jsonforms-monorepo",
33
"engines": {
4-
"node": "^16.13",
4+
"node": "^16.14",
55
"pnpm": ">=7.13.4"
66
},
77
"scripts": {
88
"lerna": "lerna",
99
"preparePublish": "git clean -dfx && pnpm i --frozen-lockfile && pnpm run clean && pnpm run build && pnpm run doc && pnpm run test",
10-
"merge-report": "mkdir -p coverage && lcov-result-merger 'packages/**/coverage/lcov.info' 'coverage/lcov.info'",
10+
"merge-report": "mkdir -p coverage && lcov-result-merger 'packages/**/coverage/lcov.info' 'coverage/lcov.info' --prepend-source-files",
1111
"check-format": "echo 'temporarily disabled'",
1212
"build": "lerna run build",
1313
"bundle": "lerna run bundle",

packages/angular-material/.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,21 @@ module.exports = {
3333
caughtErrorsIgnorePattern: '^_',
3434
},
3535
],
36+
// workaround for
37+
// https://github.com/import-js/eslint-plugin-import/issues/1810:
38+
"import/no-unresolved": [
39+
"error",
40+
{
41+
ignore: [
42+
"@angular/cdk/.*",
43+
"@angular/core/.*",
44+
"@angular/material/.*",
45+
"@angular/platform-browser/.*",
46+
"@angular/platform-browser-dynamic/.*",
47+
"core-js/es7/.*",
48+
"zone.js/.*",
49+
]
50+
}
51+
],
3652
},
3753
};

packages/angular-material/example/app/app.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const itemTester: UISchemaTester = (_schema, schemaPath, _path) => {
7474
<div>
7575
<button (click)="changeLocale('de-DE')">Change locale to de-DE</button>
7676
<button (click)="changeLocale('en-US')">Change locale to en-US</button>
77-
Current locale: {{ currentLocale }}
77+
Current locale: {{ i18n.locale }}
7878
<button (click)="toggleReadonly()">
7979
{{ readonly ? 'Unset' : 'Set' }} Readonly
8080
</button>
@@ -85,19 +85,17 @@ const itemTester: UISchemaTester = (_schema, schemaPath, _path) => {
8585
[uischema]="selectedExample.uischema"
8686
[renderers]="renderers"
8787
[i18n]="i18n"
88-
[uischemas]="uischemas"
8988
[readonly]="readonly"
90-
[config]="config"
9189
></jsonforms>
9290
`,
9391
})
9492
export class AppComponent {
9593
readonly renderers = angularMaterialRenderers;
9694
readonly examples = getExamples();
97-
selectedExample: ExampleDescription;
95+
selectedExample: ExampleDescription | undefined;
9896
i18n: JsonFormsI18nState;
9997
private dateAdapter;
100-
private readonly = false;
98+
readonly = false;
10199
data: any;
102100
uischemas: { tester: UISchemaTester; uischema: UISchemaElement }[] = [
103101
{ tester: itemTester, uischema: uiSchema },
@@ -114,7 +112,7 @@ export class AppComponent {
114112
this.selectedExample = this.examples.find(
115113
(e) => e.name === ev.target.value
116114
);
117-
this.i18n = this.selectedExample.i18n ?? defaultI18n;
115+
this.i18n = this.selectedExample?.i18n ?? defaultI18n;
118116
}
119117

120118
changeLocale(locale: string) {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage'),
13+
require('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
jasmine: {
17+
// you can add configuration options for Jasmine here
18+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19+
// for example, you can disable the random execution with `random: false`
20+
// or set a specific seed with `seed: 4321`
21+
},
22+
clearContext: false // leave Jasmine Spec Runner output visible in browser
23+
},
24+
jasmineHtmlReporter: {
25+
suppressAll: true // removes the duplicated traces
26+
},
27+
coverageReporter: {
28+
subdir: '.',
29+
reporters: [
30+
{ type: 'lcov' },
31+
{ type: 'text-summary' }
32+
]
33+
},
34+
reporters: ['progress', 'kjhtml', 'dots'],
35+
36+
browsers: [ config.singleRun ? 'ChromeHeadlessNoSandbox' : 'Chrome' ],
37+
customLaunchers: {
38+
ChromeHeadlessNoSandbox: {
39+
base: 'ChromeHeadless',
40+
flags: ['--no-sandbox'],
41+
},
42+
},
43+
restartOnFileChange: true,
44+
logLevel: config.LOG_INFO,
45+
46+
webpackMiddleware: {
47+
stats: 'detailed',
48+
},
49+
50+
webpackServer: {
51+
noInfo: true,
52+
},
53+
});
54+
};

packages/angular-material/package.json

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@
3939
"typings": "./lib/esm/index.d.ts",
4040
"scripts": {
4141
"build": "ngc && ngc -p tsconfig.cjs.json",
42-
"build:examples-app": "rollup -c rollup.example.config.js",
43-
"dev": "webpack --config webpack/webpack.dev.js && webpack-dev-server --config webpack/webpack.dev.js --env=dev --inline",
42+
"build:examples-app": "ngc -p tsconfig.example.json && rollup -c rollup.example.config.js",
43+
"dev": "pnpm run build:examples-app && npx http-server ./example/dist/ -c-1 -o",
4444
"clean": "rimraf lib coverage dist .nyc_output 2> /dev/null",
4545
"lint": "eslint .",
4646
"lint:fix": "eslint --fix .",
4747
"report": "nyc report --reporter=html",
4848
"doc": "typedoc --name 'JSON Forms Angular Material Renderers' --out docs src",
49-
"test": "karma start ./test-config/karma.conf.js --single-run",
50-
"test-ci": "karma start ./test-config/karma.conf.js --single-run",
51-
"test-cov": "karma start ./test-config/karma.conf.js --coverage --single-run",
49+
"test-dbg": "node ./test-runner",
50+
"test": "node ./test-runner --single-run",
51+
"test-ci": "node ./test-runner --single-run",
52+
"test-cov": "node ./test-runner --coverage --single-run",
5253
"e2e": "npm run e2e-update && npm run e2e-test",
5354
"e2e-test": "protractor ./test-config/protractor.conf.js",
5455
"e2e-update": "webdriver-manager update --standalone false --gecko false"
@@ -60,93 +61,94 @@
6061
]
6162
},
6263
"peerDependencies": {
63-
"@angular/animations": "^12.0.0 || ^13.0.0 || ^14.0.0",
64-
"@angular/cdk": "^12.0.0 || ^13.0.0 || ^14.0.0",
65-
"@angular/common": "^12.0.0 || ^13.0.0 || ^14.0.0",
66-
"@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0",
67-
"@angular/flex-layout": "^12.0.0-beta || ^13.0.0-beta || ^14.0.0-beta",
68-
"@angular/forms": "^12.0.0 || ^13.0.0 || ^14.0.0",
69-
"@angular/material": "^12.0.0 || ^13.0.0 || ^14.0.0",
70-
"@angular/platform-browser": "^12.0.0 || ^13.0.0 || ^14.0.0",
71-
"@angular/router": "^12.0.0 || ^13.0.0 || ^14.0.0",
64+
"@angular/animations": "^15.0.0",
65+
"@angular/cdk": "^15.0.0",
66+
"@angular/common": "^15.0.0",
67+
"@angular/core": "^15.0.0",
68+
"@angular/flex-layout": "^15.0.0-beta",
69+
"@angular/forms": "^15.0.0",
70+
"@angular/material": "^15.0.0",
71+
"@angular/platform-browser": "^15.0.0",
72+
"@angular/router": "^15.0.0",
7273
"@jsonforms/angular": "3.2.0-alpha.3",
74+
"@jsonforms/angular-test": "^3.2.0-alpha.3",
7375
"@jsonforms/core": "3.2.0-alpha.3",
74-
"core-js": "^2.5.3",
75-
"rxjs": "^6.5.3 || ^7.4.0"
76+
"rxjs": "^6.6.0 || ^7.4.0"
7677
},
7778
"dependencies": {
7879
"hammerjs": "2.0.8",
7980
"lodash": "^4.17.21"
8081
},
8182
"devDependencies": {
82-
"@angular-eslint/eslint-plugin": "^12.0.0",
83-
"@angular-eslint/eslint-plugin-template": "^12.0.0",
84-
"@angular-eslint/schematics": "^12.0.0",
85-
"@angular-eslint/template-parser": "^12.0.0",
86-
"@angular/animations": "^12.0.0",
87-
"@angular/cdk": "^12.0.0",
88-
"@angular/common": "^12.0.0",
89-
"@angular/compiler": "^12.0.0",
90-
"@angular/compiler-cli": "^12.0.0",
91-
"@angular/core": "^12.0.0",
92-
"@angular/flex-layout": "^12.0.0-beta",
93-
"@angular/forms": "^12.0.0",
94-
"@angular/material": "^12.0.0",
95-
"@angular/platform-browser": "^12.0.0",
96-
"@angular/platform-browser-dynamic": "^12.0.0",
97-
"@angular/router": "^12.0.0",
83+
"@angular-devkit/build-angular": "~15.2.10",
84+
"@angular-eslint/eslint-plugin": "^15.0.0",
85+
"@angular-eslint/eslint-plugin-template": "^15.0.0",
86+
"@angular-eslint/schematics": "^15.0.0",
87+
"@angular-eslint/template-parser": "^15.0.0",
88+
"@angular/animations": "^15.0.0",
89+
"@angular/cdk": "^15.0.0",
90+
"@angular/common": "^15.0.0",
91+
"@angular/compiler": "^15.0.0",
92+
"@angular/compiler-cli": "^15.0.0",
93+
"@angular/core": "^15.0.0",
94+
"@angular/flex-layout": "^15.0.0-beta",
95+
"@angular/forms": "^15.0.0",
96+
"@angular/material": "^15.0.0",
97+
"@angular/platform-browser": "^15.0.0",
98+
"@angular/platform-browser-dynamic": "^15.0.0",
99+
"@angular/router": "^15.0.0",
98100
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
99101
"@babel/plugin-proposal-optional-chaining": "^7.16.5",
100102
"@jsonforms/angular": "workspace:*",
101103
"@jsonforms/angular-test": "workspace:*",
102104
"@jsonforms/core": "workspace:*",
103105
"@jsonforms/examples": "workspace:*",
106+
"@ngtools/webpack": "^15.0.0",
104107
"@rollup/plugin-commonjs": "^23.0.3",
105108
"@rollup/plugin-json": "^5.0.2",
106109
"@rollup/plugin-node-resolve": "^15.0.1",
107110
"@rollup/plugin-replace": "^5.0.1",
108-
"@types/node": "^16.18.34",
111+
"@types/jasmine": "~3.8.0",
112+
"@types/lodash": "4.14.149",
113+
"@types/node": "^18.10.0",
109114
"@typescript-eslint/eslint-plugin": "^5.54.1",
110115
"@typescript-eslint/parser": "^5.54.1",
111-
"angular2-template-loader": "^0.6.2",
112116
"babel-loader": "^8.0.6",
113-
"copy-webpack-plugin": "^5.0.5",
114-
"core-js": "^2.5.3",
117+
"copy-webpack-plugin": "^11.0.0",
115118
"eslint": "^7.32.0",
116119
"eslint-config-prettier": "^8.7.0",
117120
"eslint-plugin-import": "^2.27.5",
118121
"eslint-plugin-prettier": "^4.2.1",
119122
"html-loader": "^0.5.5",
120-
"istanbul-instrumenter-loader": "^3.0.1",
123+
"http-server": "^14.1.1",
121124
"jasmine": "^3.99.0",
122125
"jasmine-spec-reporter": "^4.2.1",
123-
"karma": "^3.1.4",
126+
"karma": "^6.4.1",
124127
"karma-chrome-launcher": "^3.2.0",
125-
"karma-coverage-istanbul-reporter": "^2.1.1",
128+
"karma-coverage": "~2.0.3",
126129
"karma-jasmine": "^2.0.1",
127130
"karma-jasmine-html-reporter": "^1.7.0",
128131
"karma-sourcemap-loader": "^0.3.8",
129-
"karma-webpack": "^4.0.2",
132+
"karma-webpack": "^5.0.0",
133+
"ng-packagr": "^15.0.0",
130134
"null-loader": "^0.1.1",
131135
"nyc": "^15.1.0",
132136
"prettier": "^2.8.4",
133-
"protractor": "^5.4.1",
134-
"request": "^2.88.0",
137+
"protractor": "^7.0.0",
135138
"rimraf": "^3.0.2",
136139
"rollup": "^2.78.0",
137140
"rollup-plugin-cleanup": "^3.2.1",
138141
"rollup-plugin-copy": "^3.4.0",
139142
"rollup-plugin-import-css": "^3.3.1",
140143
"rollup-plugin-typescript2": "^0.34.1",
141144
"rollup-plugin-visualizer": "^5.4.1",
142-
"rxjs": "^6.5.3",
145+
"rxjs": "^6.6.0",
143146
"ts-loader": "^6.2.1",
144147
"tslib": "^2.5.0",
145-
"typedoc": "~0.21.9",
146-
"typescript": "4.2.3",
147-
"webpack": "^4.41.2",
148-
"webpack-cli": "^3.2.1",
149-
"webpack-dev-server": "^3.9.0",
148+
"typedoc": "~0.25.3",
149+
"typescript": "~4.9.5",
150+
"webpack": "^5.78.0",
151+
"yargs": "^17.7.2",
150152
"zone.js": "^0.11.4"
151153
}
152154
}

packages/angular-material/rollup.example.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import typescript from 'rollup-plugin-typescript2';
1010
* @type {import('rollup').RollupOptions}
1111
*/
1212
const config = {
13-
input: 'example/main.ts',
13+
input: 'example/dist/example/main.js',
1414
output: {
1515
file: 'example/dist/bundle.js',
1616
format: 'iife',

packages/angular-material/src/controls/autocomplete.renderer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export class AutocompleteControlRenderer
108108
@Input() options: string[];
109109
filteredOptions: Observable<string[]>;
110110
shouldFilter: boolean;
111+
focused = false;
111112

112113
constructor(jsonformsService: JsonFormsAngularService) {
113114
super(jsonformsService);

packages/angular-material/src/controls/date.renderer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ import { JsonFormsAngularService, JsonFormsControl } from '@jsonforms/angular';
5454
changeDetection: ChangeDetectionStrategy.OnPush,
5555
})
5656
export class DateControlRenderer extends JsonFormsControl {
57+
focused = false;
58+
5759
constructor(jsonformsService: JsonFormsAngularService) {
5860
super(jsonformsService);
5961
}

packages/angular-material/src/controls/number.renderer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export class NumberControlRenderer extends JsonFormsControl {
6969
locale: string;
7070
numberFormat: Intl.NumberFormat;
7171
decimalSeparator: string;
72+
focused = false;
7273

7374
constructor(jsonformsService: JsonFormsAngularService) {
7475
super(jsonformsService);

0 commit comments

Comments
 (0)