nx
nx copied to clipboard
feat(angular): create routes file pattern
Description
This PR introduces a pattern of separate *.routes.ts files for generated routes. The idea behind this is fairly straightforward. Routes will always live in a separate file where a variable is exported containing the array of Routes.
The motivation for this is two-fold.
- It is much easier for developers to find and reason about routing within their apps when the routes are always contained in a specific file.
- With the introduction of Standalone Components in Angular, routing to children no longer needs a
RouterModule.forChild, it simply uses a variable containing a route configuration. By introducing this pattern, we align how routing is set up for both NgModule-based and Standalone Component-based Angular workspaces. This also increases the interoperability between them.
By aligning them to follow the same pattern, we also simplify the code required to add a Route to an existing Route configuration.
Below is the file structure that will be created
| - apps
| - appName
| - src
| - app
| - app.routes.ts
| - libs
| - libName
| - src
| - lib
| - lib.routes.ts
This works for Standalone Apps and Libraries and NgModule Apps and Libraries and interops between them. It also works for Module Federated Apps, both Standalone and NgModule-based.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated |
|---|---|---|---|
| nx-dev | ✅ Ready (Inspect) | Visit Preview | Sep 14, 2022 at 4:11PM (UTC) |
☁️ Nx Cloud Report
CI is running/has finished running commands for commit ee804544625d1237cbb9030447274ce916024db8. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.
📂 See all runs for this branch
✅ Successfully ran 12 targets
nx affected --target=e2e --base=73fd49aab398198a471a6a69e4ff9bb38482aa43 --head=ee804544625d1237cbb9030447274ce916024db8 --exclude=e2e-storybook,e2e-storybook-angular,e2e-react-native,e2e-detox,e2e-make-angular-cli-faster --parallel=1nx affected --target=test --base=73fd49aab398198a471a6a69e4ff9bb38482aa43 --head=ee804544625d1237cbb9030447274ce916024db8 --parallel=1nx affected --target=build --base=73fd49aab398198a471a6a69e4ff9bb38482aa43 --head=ee804544625d1237cbb9030447274ce916024db8 --parallel=3nx-cloud record -- yarn depchecknx affected --target=lint --base=73fd49aab398198a471a6a69e4ff9bb38482aa43 --head=ee804544625d1237cbb9030447274ce916024db8 --parallel=3nx-cloud record -- yarn nx workspace-lintnx-cloud record -- yarn check-lock-filesnx-cloud record -- yarn check-commitnx-cloud record -- yarn nx format:check --base=73fd49aab398198a471a6a69e4ff9bb38482aa43 --head=ee804544625d1237cbb9030447274ce916024db8nx-cloud record -- yarn check-importsnx-cloud record -- yarn documentationnx build typedoc-theme
Sent with 💌 from NxCloud.
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.