Skip to content

Commit 33862ed

Browse files
authored
build: add Angular 16 support & update packages (#450)
Hello, This PR fixes #449. What I did: - I couldn't use `yarn` to run the nx migration so I had to switch to `npm`: - deleted `yarn.lock` - deleted `node_modules` - `npm install` - I executed the nx migration (with `npm`) to `nx 16.1` which also migrated to `Angular 16` - `npx nx migrate latest` - There was nothing related to `Angular 16` migration this time - I did not migrate to standalone nor inject pattern - I then had to update Storybook packages to `7.1.0-alpha.13` to support `Angular 16` + `Typescript 5` before installing the migrated packages - I removed `node_modules` & `package-lock.json` and switched back to `yarn` - then `yarn install` - I applied the migration - `yarn nx migrate --run-migrations` - The migration migrated Storybook to full version 7 - For more information it created `storybook-migration-summary.md` - I had to switch back again to `npm` because `caniuse-lite` wasn't installing properly with `yarn` which caused problem when building - It was missing some files in `caniuse-lite/dist/unpacker` - I updated the `.gitignore` to reflect nx project migration - Properly ignore `reports` folders - I had to explicitly install `core-js` - I also had to update the import in `test.ts` of the lib to `core-js/stable/reflect` - I added `hammerjs` in `allowedCommonJsDependencies` for the demo app - I updated all packages to latest version - I scoped package versions to maximum `patch` - After updating all packages, `caniuse-lite` was installed properly so I switched back to `yarn` 😄 - CI workflow `nodejs` now run on `Node.js 16` and `18` - `Node.js 14` is not compatible anymore with Angular - CI workflow `npm-publish` now run on `Node.js 18` - `actions/setup-node` updated to `v3` on all workflows Problems: - I was not able to fix `component-test` - I was not able to fix `storybook` Note: - Since the repo got moved to nx, it seems that some Typescript eslint rules were removed, if you want to add them back: - For `"files": ["*.ts"]` add `"plugin:@nx/typescript"` in the `"extends": [...]` array - I didn't add it cause I'm not sure how to properly fix all the problems on the project - I removed the unused comments using previous eslint setup (before nx migration) for cypress project (in `commands.ts`) TODO on your side: - Update compatibility array - Release a new major version `8.0.0` - Close branches related to package update
1 parent 54644e9 commit 33862ed

File tree

20 files changed

+4813
-8413
lines changed

20 files changed

+4813
-8413
lines changed

.eslintrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{
4242
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
4343
"rules": {
44-
"@nrwl/nx/enforce-module-boundaries": [
44+
"@nx/enforce-module-boundaries": [
4545
"error",
4646
{
4747
"enforceBuildableLibDependency": true,
@@ -57,5 +57,6 @@
5757
}
5858
}
5959
],
60-
"plugins": ["@nrwl/nx"]
60+
"plugins": ["@nx"],
61+
"extends": ["plugin:storybook/recommended"]
6162
}

.github/workflows/nodejs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: ['14', '16']
18+
node-version: ['16', '18']
1919

2020
steps:
2121
- uses: actions/checkout@v3
2222
- name: Use Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v1
23+
uses: actions/setup-node@v3
2424
with:
2525
node-version: ${{ matrix.node-version }}
2626
- name: Install dependencies
2727
run: yarn
2828
- name: Build
2929
run: |
30-
yarn nx run-many --target=build --all
30+
yarn nx run-many --target=build --all
3131
env:
3232
CI: true

.github/workflows/npm-publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v3
18-
- uses: actions/setup-node@v2
18+
- uses: actions/setup-node@v3
1919
with:
20-
node-version: 16
20+
node-version: 18
2121
- run: yarn
2222

2323
publish-npm:
2424
needs: build
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v3
28-
- uses: actions/setup-node@v2
28+
- uses: actions/setup-node@v3
2929
with:
30-
node-version: 16
30+
node-version: 18
3131
registry-url: https://registry.npmjs.org/
3232
scope: '@ngu'
3333
- name: Build and Publish
3434
run: |
3535
yarn install
36-
yarn nx run-many --target=build --all
36+
yarn nx run-many --target=build --all
3737
cd dist/libs/ngu/carousel
3838
npm publish --access=public
3939
shell: bash

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ npm-debug.log
4040
yarn-error.log
4141
testem.log
4242
/typings
43-
/reports
44-
/projects/*/reports
43+
**/reports
4544

4645
# System Files
4746
.DS_Store
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { defineConfig } from 'cypress';
2-
import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';
2+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
33

44
export default defineConfig({
55
e2e: {
66
...nxE2EPreset(__dirname),
77
/**
8-
* TODO(@nrwl/cypress): In Cypress v12,the testIsolation option is turned on by default.
9-
* This can cause tests to start breaking where not indended.
10-
* You should consider enabling this once you verify tests do not depend on each other
11-
* More Info: https://docs.cypress.io/guides/references/migration-guide#Test-Isolation
12-
**/
13-
testIsolation: false,
8+
* TODO(@nx/cypress): In Cypress v12,the testIsolation option is turned on by default.
9+
* This can cause tests to start breaking where not indended.
10+
* You should consider enabling this once you verify tests do not depend on each other
11+
* More Info: https://docs.cypress.io/guides/references/migration-guide#Test-Isolation
12+
**/
13+
testIsolation: false
1414
}
1515
});

apps/ngu-carousel-e2e/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"projectType": "application",
66
"targets": {
77
"e2e": {
8-
"executor": "@nrwl/cypress:cypress",
8+
"executor": "@nx/cypress:cypress",
99
"options": {
1010
"cypressConfig": "apps/ngu-carousel-e2e/cypress.config.ts",
1111
"devServerTarget": "ngu-carousel-example:serve:development",
@@ -18,7 +18,7 @@
1818
}
1919
},
2020
"lint": {
21-
"executor": "@nrwl/linter:eslint",
21+
"executor": "@nx/linter:eslint",
2222
"outputs": ["{options.outputFile}"],
2323
"options": {
2424
"lintFilePatterns": ["apps/ngu-carousel-e2e/**/*.{js,ts}"]

apps/ngu-carousel-e2e/src/support/commands.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
// https://on.cypress.io/custom-commands
99
// ***********************************************
1010

11-
// eslint-disable-next-line @typescript-eslint/no-namespace
1211
declare namespace Cypress {
13-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1412
interface Chainable<Subject> {
1513
login(email: string, password: string): void;
1614
}

apps/ngu-carousel-example/cypress/support/commands.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
// https://on.cypress.io/custom-commands
1010
// ***********************************************
1111

12-
// eslint-disable-next-line @typescript-eslint/no-namespace
1312
declare namespace Cypress {
14-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1513
interface Chainable<Subject> {
1614
login(email: string, password: string): void;
1715
}

apps/ngu-carousel-example/project.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
3232
"apps/ngu-carousel-example/src/styles.scss"
3333
],
34-
"scripts": []
34+
"scripts": [],
35+
"allowedCommonJsDependencies": [
36+
"hammerjs"
37+
]
3538
},
3639
"configurations": {
3740
"production": {
@@ -95,7 +98,7 @@
9598
}
9699
},
97100
"lint": {
98-
"executor": "@nrwl/linter:eslint",
101+
"executor": "@nx/linter:eslint",
99102
"options": {
100103
"lintFilePatterns": [
101104
"apps/ngu-carousel-example/**/*.ts",
@@ -104,7 +107,7 @@
104107
}
105108
},
106109
"component-test": {
107-
"executor": "@nrwl/cypress:cypress",
110+
"executor": "@nx/cypress:cypress",
108111
"options": {
109112
"cypressConfig": "apps/ngu-carousel-example/cypress.config.ts",
110113
"testingType": "component"

decorate-angular-cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ const cp = require('child_process');
2626
const isWindows = os.platform() === 'win32';
2727
let output;
2828
try {
29-
output = require('@nrwl/workspace').output;
29+
output = require('@nx/workspace').output;
3030
} catch (e) {
3131
console.warn(
32-
'Angular CLI could not be decorated to enable computation caching. Please ensure @nrwl/workspace is installed.'
32+
'Angular CLI could not be decorated to enable computation caching. Please ensure @nx/workspace is installed.'
3333
);
3434
process.exit(0);
3535
}

0 commit comments

Comments
 (0)