Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update to latest angular and nx #308

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx", "@ngrx"],
"plugins": ["@nx", "@ngrx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
Expand All @@ -23,7 +23,7 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
Expand All @@ -32,7 +32,7 @@
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
Expand Down
4 changes: 2 additions & 2 deletions decorate-angular-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const cp = require('child_process');
const isWindows = os.platform() === 'win32';
let output;
try {
output = require('@nrwl/workspace').output;
output = require('@nx/workspace').output;
} catch (e) {
console.warn(
'Angular CLI could not be decorated to enable computation caching. Please ensure @nrwl/workspace is installed.'
'Angular CLI could not be decorated to enable computation caching. Please ensure @nx/workspace is installed.'
);
process.exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getJestProjects } = require('@nrwl/jest');
const { getJestProjects } = require('@nx/jest');

export default {
projects: getJestProjects(),
Expand Down
16 changes: 14 additions & 2 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
const nxPreset = require('@nrwl/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
module.exports = {
...nxPreset,
/* TODO: Update to latest Jest snapshotFormat
yharaskrik marked this conversation as resolved.
Show resolved Hide resolved
* By default Nx has kept the older style of Jest Snapshot formats
* to prevent breaking of any existing tests with snapshots.
* It's recommend you update to the latest format.
* You can do this by removing snapshotFormat property
* and running tests with --update-snapshot flag.
* Example: "nx affected --targets=test --update-snapshot"
* More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
*/
snapshotFormat: { escapeString: true, printBasicPrototype: true },
};
25 changes: 13 additions & 12 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"]
}
}
},
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"extends": "nx/presets/npm.json",
"npmScope": "ngworker",
Expand All @@ -15,14 +23,6 @@
},
".eslintrc.json": "*"
},
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
Expand All @@ -46,25 +46,26 @@
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/**/*.spec.[jt]s"
"!{projectRoot}/**/*.spec.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s"
],
"sharedGlobals": []
},
"generators": {
"@nrwl/angular:application": {
"@nx/angular:application": {
"style": "css",
"linter": "eslint",
"unitTestRunner": "jest",
"e2eTestRunner": "cypress"
},
"@nrwl/angular:library": {
"@nx/angular:library": {
"linter": "eslint",
"unitTestRunner": "jest"
},
"@schematics/angular:component": {
"style": "css"
},
"@nrwl/angular:component": {
"@nx/angular:component": {
"style": "css"
}
},
Expand Down
78 changes: 40 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,67 @@
"postinstall": "node ./decorate-angular-cli.js",
"build": "nx run-many --target=build --all",
"ci": "yarn lint && yarn test && yarn build",
"lint": "nx workspace-lint && nx run-many --target=lint --all --max-warnings=0",
Copy link
Author

Choose a reason for hiding this comment

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

this command is no longer needed.

"lint": "nx run-many --target=lint --all --max-warnings=0",
"nx": "nx",
"test": "nx run-many --target=test --all"
},
"engines": {
"node": "16.19.0",
"node": "^18.17.0",
"yarn": "1.22.19"
},
"volta": {
"node": "16.19.0",
"node": "^18.17.0",
"yarn": "1.22.19"
},
"dependencies": {
"@angular/common": "15.0.4",
"@angular/compiler": "15.0.4",
"@angular/core": "15.0.4",
"@angular/platform-browser": "15.0.4",
"@angular/platform-browser-dynamic": "15.0.4",
"@angular/router": "15.0.4",
"@ngrx/component-store": "15.0.0",
"@ngrx/router-store": "15.0.0",
"@ngrx/store": "15.0.0",
"@nrwl/angular": "15.3.3",
"@angular/common": "16.2.6",
"@angular/compiler": "16.2.6",
"@angular/core": "16.2.6",
"@angular/platform-browser": "16.2.6",
"@angular/platform-browser-dynamic": "16.2.6",
"@angular/router": "16.2.6",
"@ngrx/component-store": "16.2.0",
"@ngrx/router-store": "16.2.0",
"@ngrx/store": "16.2.0",
"rxjs": "7.4.0",
"tslib": "2.4.1",
"zone.js": "0.12.0"
"zone.js": "0.13.3",
"@nx/angular": "16.9.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "15.0.4",
"@angular-eslint/eslint-plugin": "15.0.0",
"@angular-eslint/eslint-plugin-template": "15.0.0",
"@angular-eslint/template-parser": "15.0.0",
"@angular/cli": "15.0.4",
"@angular/compiler-cli": "15.0.4",
"@angular/language-service": "15.0.4",
"@ngrx/eslint-plugin": "15.0.0",
"@nrwl/cli": "15.3.3",
"@nrwl/eslint-plugin-nx": "15.3.3",
"@nrwl/jest": "15.3.3",
"@nrwl/linter": "15.3.3",
"@nrwl/workspace": "15.3.3",
"@types/jest": "28.1.8",
"@angular-devkit/build-angular": "16.2.3",
"@angular-devkit/core": "16.2.3",
"@angular-devkit/schematics": "16.2.3",
"@angular-eslint/eslint-plugin": "16.0.3",
"@angular-eslint/eslint-plugin-template": "16.0.3",
"@angular-eslint/template-parser": "16.0.3",
"@angular/cli": "~16.2.0",
"@angular/compiler-cli": "16.2.6",
"@angular/language-service": "16.2.6",
"@ngrx/eslint-plugin": "16.0.1",
"@schematics/angular": "16.2.3",
"@types/jest": "29.4.4",
"@types/node": "16.11.7",
"@typescript-eslint/eslint-plugin": "5.36.1",
"@typescript-eslint/parser": "5.36.1",
"eslint": "8.15.0",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.46.0",
"eslint-config-prettier": "8.1.0",
"jest": "28.1.3",
"jest-environment-jsdom": "28.1.1",
"jest-preset-angular": "12.2.3",
"ng-packagr": "15.0.3",
"nx": "15.3.3",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"jest-preset-angular": "13.1.2",
"ng-packagr": "16.2.3",
"nx": "16.9.0",
"postcss": "8.4.18",
"postcss-import": "14.1.0",
"postcss-preset-env": "7.5.0",
"postcss-url": "10.1.3",
"prettier": "2.7.1",
"ts-jest": "28.0.8",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typescript": "4.8.4"
"typescript": "5.1.6",
"@nx/workspace": "16.9.0",
"@nx/linter": "16.9.0",
"@nx/eslint-plugin": "16.9.0",
"@nx/jest": "16.9.0"
}
}
4 changes: 2 additions & 2 deletions packages/router-component-store/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"files": ["*.ts"],
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
Expand All @@ -29,7 +29,7 @@
},
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
Expand Down
15 changes: 8 additions & 7 deletions packages/router-component-store/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ export default {
displayName: 'router-component-store',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
},
globals: {},
coverageDirectory: '../../coverage/packages/router-component-store',
transform: {
'^.+.(ts|mjs|js|html)$': 'jest-preset-angular',
'^.+.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*.mjs$)'],
snapshotSerializers: [
Expand Down
6 changes: 3 additions & 3 deletions packages/router-component-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "An Angular Router-connecting NgRx component store.",
"license": "MIT",
"peerDependencies": {
"@angular/core": "^15.0.0",
"@angular/router": "^15.0.0",
"@ngrx/component-store": "^15.0.0",
"@angular/core": "^15.0.0 || ^16.0.0",
Copy link
Author

Choose a reason for hiding this comment

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

Can confirm it DOES work in 16, we have been using it for a while.

Copy link
Member

@LayZeeDK LayZeeDK Sep 26, 2023

Choose a reason for hiding this comment

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

I have recently put the library into production in a big Angular 16 app with complex routing configurations and route state usage and I can also confirm this. However, Router Component Store will follow the versioning scheme recommended by Angular: One major version of Router Component Store for every major version of Angular (and NgRx Component Store).

"@angular/router": "^15.0.0 || ^16.0.0",
"@ngrx/component-store": "^15.0.0 || ^16.0.0",
"rxjs": "^7.4.0"
},
"dependencies": {
Expand Down
9 changes: 5 additions & 4 deletions packages/router-component-store/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"prefix": "ngw",
"targets": {
"build": {
"executor": "@nrwl/angular:package",
"executor": "@nx/angular:package",
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
"options": {
"project": "packages/router-component-store/ng-package.json"
"project": "packages/router-component-store/ng-package.json",
"updateBuildableProjectDepsInPackageJson": true
},
"configurations": {
"production": {
Expand All @@ -22,15 +23,15 @@
"defaultConfiguration": "production"
},
"test": {
"executor": "@nrwl/jest:jest",
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/router-component-store/jest.config.ts",
"passWithNoTests": true
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"executor": "@nx/linter:eslint",
"options": {
"lintFilePatterns": [
"packages/router-component-store/src/**/*.ts",
Expand Down
3 changes: 2 additions & 1 deletion packages/router-component-store/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
"types": ["jest", "node"],
"target": "es2016"
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
Expand Down
Empty file removed tools/generators/.gitkeep
Empty file.
Loading