Skip to content

Commit 49bf89f

Browse files
authored
feat: Nx 20.3+ with Angular 19 support with optional zoneless (#82)
1 parent 60bae8a commit 49bf89f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1234
-758
lines changed

migrations.json

+36-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
{
22
"migrations": [
33
{
4-
"version": "20.0.1",
5-
"description": "Set `useLegacyCache` to true for migrating workspaces",
6-
"implementation": "./src/migrations/update-20-0-1/use-legacy-cache",
7-
"x-repair-skip": true,
8-
"package": "nx",
9-
"name": "use-legacy-cache"
4+
"version": "20.2.0-beta.5",
5+
"description": "Update TypeScript ESLint packages to v8.13.0 if they are already on v8",
6+
"implementation": "./src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0",
7+
"package": "@nx/eslint",
8+
"name": "update-typescript-eslint-v8.13.0"
9+
},
10+
{
11+
"version": "20.3.0-beta.1",
12+
"description": "Update ESLint flat config to include .cjs, .mjs, .cts, and .mts files in overrides (if needed)",
13+
"implementation": "./src/migrations/update-20-3-0/add-file-extensions-to-overrides",
14+
"package": "@nx/eslint",
15+
"name": "add-file-extensions-to-overrides"
16+
},
17+
{
18+
"cli": "nx",
19+
"version": "20.2.0-beta.2",
20+
"description": "Update the ModuleFederationConfig import use @nx/module-federation.",
21+
"factory": "./src/migrations/update-20-2-0/migrate-mf-imports-to-new-package",
22+
"package": "@nx/angular",
23+
"name": "update-20-2-0-update-module-federation-config-import"
24+
},
25+
{
26+
"cli": "nx",
27+
"version": "20.2.0-beta.2",
28+
"description": "Update the withModuleFederation import use @nx/module-federation/angular.",
29+
"factory": "./src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package",
30+
"package": "@nx/angular",
31+
"name": "update-20-2-0-update-with-module-federation-import"
32+
},
33+
{
34+
"cli": "nx",
35+
"version": "20.3.0-beta.2",
36+
"description": "If workspace includes Module Federation projects, ensure the new @nx/module-federation package is installed.",
37+
"factory": "./src/migrations/update-20-3-0/ensure-nx-module-federation-package",
38+
"package": "@nx/angular",
39+
"name": "ensure-nx-module-federation-package"
1040
}
1141
]
1242
}

package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,22 @@
3131
},
3232
"private": true,
3333
"devDependencies": {
34-
"@angular-devkit/core": "~18.2.0",
35-
"@nx/angular": "20.0.3",
36-
"@nx/devkit": "20.0.3",
37-
"@nx/eslint": "20.0.3",
38-
"@nx/eslint-plugin": "20.0.3",
39-
"@nx/express": "20.0.3",
40-
"@nx/jest": "20.0.3",
41-
"@nx/js": "20.0.3",
42-
"@nx/plugin": "20.0.3",
43-
"@nx/web": "20.0.3",
44-
"@nx/workspace": "20.0.3",
34+
"@angular-devkit/core": "~19.0.0",
35+
"@nx/angular": "20.3.0",
36+
"@nx/devkit": "20.3.0",
37+
"@nx/eslint": "20.3.0",
38+
"@nx/eslint-plugin": "20.3.0",
39+
"@nx/express": "20.3.0",
40+
"@nx/jest": "20.3.0",
41+
"@nx/js": "20.3.0",
42+
"@nx/plugin": "20.3.0",
43+
"@nx/web": "20.3.0",
44+
"@nx/workspace": "20.3.0",
4545
"@types/fs-extra": "^11.0.3",
4646
"@types/jest": "29.5.13",
4747
"@types/node": "^20.0.0",
4848
"@types/plist": "^3.0.2",
49+
"@typescript-eslint/utils": "^8.13.0",
4950
"conventional-changelog-cli": "^5.0.0",
5051
"cz-conventional-changelog": "^3.3.0",
5152
"doctoc": "^2.0.0",
@@ -56,7 +57,7 @@
5657
"fast-xml-parser": "^4.5.0",
5758
"fs-extra": "^11.2.0",
5859
"jest": "29.7.0",
59-
"nx": "20.0.3",
60+
"nx": "20.3.0",
6061
"nx-cloud": "19.1.0",
6162
"plist": "^3.1.0",
6263
"prettier": "^3.3.0",
@@ -67,4 +68,3 @@
6768
},
6869
"dependencies": {}
6970
}
70-

packages/nx/README.md

+19-25
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ If updating from Nx <= 19 to >=20, [see the migration guide](https://github.com./
2121
- [NativeScript Plugin for Nx](#nativescript-plugin-for-nx)
2222
- [Table of Contents](#table-of-contents)
2323
- [Getting started](#getting-started)
24-
- [Create a new Nx workspace](#create-a-new-nx-workspace)
25-
- [Init workspace](#init-workspace)
26-
- [Install NativeScript plugin](#install-nativescript-plugin)
27-
- [Create an app](#create-an-app)
24+
- [1. Create a new Nx workspace](#1-create-a-new-nx-workspace)
25+
- [2. Init workspace](#2-init-workspace)
26+
- [3. Install NativeScript plugin](#3-install-nativescript-plugin)
27+
- [4. Create an app](#4-create-an-app)
2828
- [`--framework [angular|vanilla]`](#--framework-angularvanilla)
2929
- [`--groupByName`](#--groupbyname)
3030
- [Develop on simulators and devices](#develop-on-simulators-and-devices)
@@ -44,42 +44,33 @@ If updating from Nx <= 19 to >=20, [see the migration guide](https://github.com./
4444

4545
## Getting started
4646

47-
### Create a new Nx workspace
47+
### 1. Create a new Nx workspace
4848

4949
```sh
5050
# Using npm
51-
npx create-nx-workspace@latest
51+
npx create-nx-workspace@latest --preset=apps
5252

5353
# Using yarn
54-
yarn create-nx-workspace@latest
54+
yarn create-nx-workspace@latest --preset=apps
5555
```
5656

57-
At the prompts, you can use:
57+
The prompts may vary with different Nx versions, but for the following you can use:
5858

5959
```sh
6060
✔ Where would you like to create your workspace? · {your-workspace-name}
6161

62-
? Which stack do you want to use?
63-
None: Configures a minimal structure without specific frameworks or technologies.
64-
# Choose "None"
65-
66-
? Package-based monorepo, integrated monorepo, or standalone project?
67-
Integrated Monorepo: Nx creates a monorepo that contains multiple projects.
68-
# Choose "Integrated"
69-
70-
? Do you want Nx Cloud to make your CI fast?
71-
# Choice is completely up to you
62+
? Which CI provider would you like to use? … {your choice}
7263
```
7364

74-
### Init workspace
65+
### 2. Init workspace
7566

7667
Initialize a TypeScript project -- This will ensure a `tsconfig.base.json` is created to begin building your workspace.
7768

7869
```sh
7970
npx nx g @nx/js:init
8071
```
8172

82-
### Install NativeScript plugin
73+
### 3. Install NativeScript plugin
8374

8475
```sh
8576
# Using npm
@@ -99,7 +90,7 @@ npm WARN node_modules/@swc/core
9990
npm WARN peer @swc/core@">= 1.3" from @swc-node/[email protected]
10091
```
10192

102-
### Create an app
93+
### 4. Create an app
10394

10495
```sh
10596
# Using npm
@@ -109,6 +100,9 @@ npx nx g @nativescript/nx:app <app-name> [...options]
109100
yarn nx g @nativescript/nx:app <app-name> [...options]
110101
```
111102

103+
**NOTE**: It's recommended to put inside an `apps` folder for good organization, eg: `apps/nativescript-<app-name>`.
104+
You can use further subfolders if you prefer as well.
105+
112106
This will generate:
113107

114108
```
@@ -144,13 +138,13 @@ apps/<app-name>-nativescript
144138
**Android:**
145139

146140
```sh
147-
npx nx run <app-name>:android
141+
npx nx debug <app-name> android
148142
```
149143

150144
**iOS:** (Mac only)
151145

152146
```sh
153-
npx nx run <app-name>:ios
147+
npx nx debug <app-name> ios
154148
```
155149

156150
#### Configuration options
@@ -268,7 +262,7 @@ Here's an example app config:
268262
}
269263
},
270264
"configurations": {
271-
"production": {
265+
"prod": {
272266
"production": true,
273267
"release": true,
274268
"android": {
@@ -434,7 +428,7 @@ npx nx build <app-name> android --c=prod \
434428
**iOS:** (Mac only)
435429

436430
```sh
437-
npx nx build <app-name> iod --c=prod
431+
npx nx build <app-name> ios --c=prod
438432
```
439433

440434
As mentioned, you can pass any additional NativeScript CLI options as flags on the end of your nx build command:

packages/nx/src/generators/application/application.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export async function applicationGenerator(tree: Tree, schema: ApplicationSchema
3636

3737
createFiles(tree, options);
3838
// add extra files per options
39-
if (options.routing && ['angular'].includes(options.framework)) {
40-
createFiles(tree, options, 'routing');
41-
}
39+
// if (options.routing && ['angular'].includes(options.framework)) {
40+
// createFiles(tree, options, 'routing');
41+
// }
4242
// add app resources
4343
appResources(tree, {
4444
path: options.projectRoot,

packages/nx/src/generators/application/files_angular/__dot__gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ platforms/
99
!eslint.config.js
1010
!ngcc.config.js
1111
!webpack.config.js
12+
!tailwind.config.js
1213
!jest.config.js
1314
*.css
1415

packages/nx/src/generators/application/files_angular/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
"main": "./src/main.ts",
44
"license": "SEE LICENSE IN <your-license-filename>",
55
"version": "0.0.0",
6-
"scripts": {
7-
"postinstall": "node ./tools/postinstall.js"
8-
},
96
"dependencies": {
107
"@nativescript/core": "*"
118
},
129
"devDependencies": {
1310
"@nativescript/android": "<%= nsAndroidRuntimeVersion %>",
14-
"@nativescript/ios": "<%= nsIOSRuntimeVersion %>"
11+
"@nativescript/ios": "<%= nsIOSRuntimeVersion %>",
12+
"@nativescript/tailwind": "<%= nsTailwindVersion %>"
1513
}
1614
}

packages/nx/src/generators/application/files_angular/src/app.android.scss

-2
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
<% if (routing) { %><GridLayout> <page-router-outlet></page-router-outlet> </GridLayout><% } else { %>
2-
<ActionBar title="My App" class="action-bar"> </ActionBar>
3-
<StackLayout class="page p-20"> <Label text="Hello" class="h1 text-center c-white"></Label> </StackLayout><% } %>
1+
<GridLayout>
2+
<page-router-outlet></page-router-outlet>
3+
</GridLayout>
4+
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Component } from '@angular/core';
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { PageRouterOutlet } from '@nativescript/angular';
23

34
@Component({
4-
selector: 'app-root',
5-
templateUrl: './app.component.html'
5+
selector: 'ns-app',
6+
templateUrl: './app.component.html',
7+
imports: [PageRouterOutlet],
8+
schemas: [NO_ERRORS_SCHEMA],
69
})
7-
export class AppComponent {
8-
9-
}
10+
export class AppComponent {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

packages/nx/src/generators/application/files_angular/src/app.ios.scss

-2
This file was deleted.

packages/nx/src/generators/application/files_angular/src/app.module.ts__tmpl__

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Routes } from '@angular/router';
2+
import { HomeComponent } from './features/home/home.component';
3+
import { DetailComponent } from './features/detail/detail.component';
4+
5+
export const routes: Routes = [
6+
{ path: '', redirectTo: '/home', pathMatch: 'full' },
7+
{ path: 'home', component: HomeComponent },
8+
{ path: 'item/:id', component: DetailComponent },
9+
];

packages/nx/src/generators/application/files_angular/src/core/core.module.ts__tmpl__

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Injectable, signal } from '@angular/core'
2+
3+
export interface Item {
4+
id: number
5+
name: string
6+
role: string
7+
}
8+
9+
@Injectable({
10+
providedIn: 'root',
11+
})
12+
export class ItemService {
13+
items = signal<Item[]>([
14+
{ id: 1, name: 'NativeScript', role: 'Technology' },
15+
{ id: 2, name: 'Ter Stegen', role: 'Goalkeeper' },
16+
{ id: 3, name: 'Piqué', role: 'Defender' },
17+
{ id: 4, name: 'I. Rakitic', role: 'Midfielder' },
18+
{ id: 5, name: 'Sergio', role: 'Midfielder' },
19+
{ id: 6, name: 'Denis Suárez', role: 'Midfielder' },
20+
{ id: 7, name: 'Arda', role: 'Midfielder' },
21+
{ id: 8, name: 'A. Iniesta', role: 'Midfielder' },
22+
{ id: 9, name: 'Suárez', role: 'Forward' },
23+
{ id: 10, name: 'Messi', role: 'Forward' },
24+
{ id: 11, name: 'Neymar', role: 'Forward' },
25+
{ id: 12, name: 'Rafinha', role: 'Midfielder' },
26+
{ id: 13, name: 'Cillessen', role: 'Goalkeeper' },
27+
{ id: 14, name: 'Mascherano', role: 'Defender' },
28+
{ id: 17, name: 'Paco Alcácer', role: 'Forward' },
29+
{ id: 18, name: 'Jordi Alba', role: 'Defender' },
30+
{ id: 19, name: 'Digne', role: 'Defender' },
31+
{ id: 20, name: 'Sergi Roberto', role: 'Midfielder' },
32+
{ id: 21, name: 'André Gomes', role: 'Midfielder' },
33+
{ id: 22, name: 'Aleix Vidal', role: 'Midfielder' },
34+
{ id: 23, name: 'Umtiti', role: 'Defender' },
35+
{ id: 24, name: 'Mathieu', role: 'Defender' },
36+
{ id: 25, name: 'Masip', role: 'Goalkeeper' }
37+
]);
38+
39+
getItem(id: number): Item {
40+
return this.items().find((item) => item.id === id)
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<ActionBar title="Details"></ActionBar>
2+
3+
<FlexboxLayout flexDirection="column">
4+
<FlexboxLayout class="m-4">
5+
<Label class="text-3xl text-gray-400" [text]="item()?.id + '. '"></Label>
6+
<Label class="text-3xl" [text]="item()?.name"></Label>
7+
</FlexboxLayout>
8+
<Label class="text-xl m-4" [text]="item()?.role"></Label>
9+
</FlexboxLayout>

0 commit comments

Comments
 (0)