You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -290,9 +288,9 @@ When you develop your Angular application, usually all your logic sits in the `a
290
288
│ │ │ ├─ cart
291
289
│ │ │ ├─ ui
292
290
│ │ │ ├─ ...
293
-
│ │ │ └─ app.tsx
291
+
│ │ │ └─ app.ts
294
292
│ │ ├─ ...
295
-
│ │ └─ main.tsx
293
+
│ │ └─ main.ts
296
294
│ ├─ ...
297
295
│ └─ project.json
298
296
├─ nx.json
@@ -314,9 +312,9 @@ Nx allows you to separate this logic into "local libraries". The main benefits i
314
312
Let's assume our domain areas include `products`, `orders` and some more generic design system components, called `ui`. We can generate a new library for each of these areas using the Angular library generator:
315
313
316
314
```
317
-
npx nx g @nx/angular:library libs/products --standalone
318
-
npx nx g @nx/angular:library libs/orders --standalone
319
-
npx nx g @nx/angular:library libs/shared/ui --standalone
315
+
npx nx g @nx/angular:library libs/products
316
+
npx nx g @nx/angular:library libs/orders
317
+
npx nx g @nx/angular:library libs/shared/ui
320
318
```
321
319
322
320
Note how we type out the full path in the `directory` flag to place the libraries into a subfolder. You can choose whatever folder structure you like to organize your projects. If you change your mind later, you can run the [move generator](/nx-api/workspace/generators/move) to move a project to a different folder.
@@ -384,51 +382,56 @@ All libraries that we generate automatically have aliases created in the root-le
384
382
}
385
383
```
386
384
387
-
Hence we can easily import them into other libraries and our Angular application. As an example, let's use the pre-generated `ProductsComponent` component from our `libs/products` library.
385
+
Hence we can easily import them into other libraries and our Angular application. As an example, let's use the pre-generated `Products` component from our `libs/products` library.
388
386
389
-
You can see that the `ProductsComponent` is exported via the `index.ts` file of our `products` library so that other projects in the repository can use it. This is our public API with the rest of the workspace. Only export what's really necessary to be usable outside the library itself.
387
+
You can see that the `Products` is exported via the `index.ts` file of our `products` library so that other projects in the repository can use it. This is our public API with the rest of the workspace. Only export what's really necessary to be usable outside the library itself.
390
388
391
389
```ts {% fileName="libs/products/src/index.ts" %}
392
-
export*from'./lib/products/products.component';
390
+
export*from'./lib/products/products';
393
391
```
394
392
395
393
We're ready to import it into our main application now. First (if you haven't already), let's set up the Angular router. Configure it in the `app.config.ts`.
Then we can add the `ProductsComponent` component to our `app.routes.ts` and render it via the routing mechanism whenever a user hits the `/products` route.
419
+
Then we can add the `Products` component to our `app.routes.ts` and render it via the routing mechanism whenever a user hits the `/products` route.
@@ -439,51 +442,51 @@ Serving your app (`npx nx serve angular-store`) and then navigating to `/product
439
442
440
443
Let's apply the same for our `orders` library.
441
444
442
-
- import the `OrdersComponent` from `libs/orders` into the `app.routes.ts` and render it via the routing mechanism whenever a user hits the `/orders` route
445
+
- import the `Orders` from `libs/orders` into the `app.routes.ts` and render it via the routing mechanism whenever a user hits the `/orders` route
443
446
444
447
In the end, your `app.routes.ts` should look similar to this:
Copy file name to clipboardExpand all lines: nx-dev/tutorial/src/content/tutorial/3-angular-monorepo/2a-smart-monorepo/11-module-boundaries/_solution/libs/products/src/lib/products.tsx
Copy file name to clipboardExpand all lines: nx-dev/tutorial/src/content/tutorial/3-angular-monorepo/2a-smart-monorepo/11-module-boundaries/content.mdx
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,9 @@ To enforce the rules, Nx ships with a custom ESLint rule. Open the `eslint.confi
53
53
54
54
```
55
55
56
-
To test it, go to your `libs/products/src/lib/products.tsx` file and import the `Orders` component from the `orders` project:
56
+
To test it, go to your `libs/products/src/lib/products/products.ts` file and import the `Orders` component from the `orders` project:
Copy file name to clipboardExpand all lines: nx-dev/tutorial/src/content/tutorial/3-angular-monorepo/2a-smart-monorepo/2-use-preset/_solution/angular-monorepo/apps/angular-store/project.json
0 commit comments