|
| 1 | +# Debugging |
| 2 | + |
| 3 | +This document is for maintainers and contributors working inside the Analog monorepo. |
| 4 | + |
| 5 | +For consumer-facing debug flags and scope reference, see the public guide in `apps/docs-app/docs/guides/debugging.md`. |
| 6 | + |
| 7 | +This repo-local file covers the monorepo-specific workflow that does not belong in the public docs site. |
| 8 | + |
| 9 | +## Repo Root Commands |
| 10 | + |
| 11 | +From this workspace, the common debug flow is to run commands from the repo root with `pnpm` or `pnpm nx`. |
| 12 | + |
| 13 | +```bash |
| 14 | +# Serve the default dev app with all Analog scopes |
| 15 | +DEBUG=analog:* pnpm dev |
| 16 | + |
| 17 | +# Build from the repo root with selected scopes |
| 18 | +DEBUG=analog:platform:routes,analog:angular:compiler pnpm build |
| 19 | + |
| 20 | +# Serve a specific app target through Nx |
| 21 | +DEBUG=analog:platform:* pnpm nx serve docs-app |
| 22 | +``` |
| 23 | + |
| 24 | +## Package Development |
| 25 | + |
| 26 | +When debugging package changes in this monorepo, prefer the project-level Nx targets so you stay on the same workspace graph and dependency layout as CI: |
| 27 | + |
| 28 | +```bash |
| 29 | +# Focus on Angular plugin HMR/style behavior |
| 30 | +DEBUG=analog:angular:hmr,analog:angular:styles pnpm nx test vite-plugin-angular |
| 31 | + |
| 32 | +# Focus on platform routing output |
| 33 | +DEBUG=analog:platform:routes pnpm nx build platform |
| 34 | + |
| 35 | +# Focus on the style-pipeline integration seam in a served app |
| 36 | +DEBUG=analog:platform:style-pipeline,analog:angular:style-pipeline pnpm nx serve your-app |
| 37 | +``` |
| 38 | + |
| 39 | +## Debugging a local Analog checkout from another pnpm workspace |
| 40 | + |
| 41 | +If you want to debug this checkout while serving a different app on your machine, |
| 42 | +point that consumer workspace at the built Analog package outputs under |
| 43 | +`/path/to/analog/packages/*/dist`. |
| 44 | + |
| 45 | +Use the built `dist` directories, not the raw package roots. Build the packages |
| 46 | +first so each `dist` folder contains its generated `package.json`. The source |
| 47 | +package manifests still contain `catalog:` and `workspace:*` references that are |
| 48 | +only rewritten during Analog's release-style build pipeline. |
| 49 | + |
| 50 | +### Local checkout example |
| 51 | + |
| 52 | +`pnpm-workspace.yaml` |
| 53 | + |
| 54 | +```yaml |
| 55 | +packages: |
| 56 | + - 'apps/*' |
| 57 | + - 'libs/**' |
| 58 | + |
| 59 | +overrides: |
| 60 | + '@analogjs/platform': file:/path/to/analog/packages/platform/dist |
| 61 | + '@analogjs/router': file:/path/to/analog/packages/router/dist |
| 62 | + '@analogjs/vite-plugin-angular': file:/path/to/analog/packages/vite-plugin-angular/dist |
| 63 | + '@analogjs/vite-plugin-nitro': file:/path/to/analog/packages/vite-plugin-nitro/dist |
| 64 | + '@analogjs/vitest-angular': file:/path/to/analog/packages/vitest-angular/dist |
| 65 | +``` |
| 66 | +
|
| 67 | +Root `package.json` |
| 68 | + |
| 69 | +```json |
| 70 | +{ |
| 71 | + "dependencies": { |
| 72 | + "@analogjs/platform": "file:/path/to/analog/packages/platform/dist" |
| 73 | + }, |
| 74 | + "overrides": { |
| 75 | + "@analogjs/platform": "file:/path/to/analog/packages/platform/dist", |
| 76 | + "@analogjs/router": "file:/path/to/analog/packages/router/dist", |
| 77 | + "@analogjs/vite-plugin-angular": "file:/path/to/analog/packages/vite-plugin-angular/dist", |
| 78 | + "@analogjs/vite-plugin-nitro": "file:/path/to/analog/packages/vite-plugin-nitro/dist", |
| 79 | + "@analogjs/vitest-angular": "file:/path/to/analog/packages/vitest-angular/dist" |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +:::important |
| 85 | +Keep the overrides in both places. If you only pin `@analogjs/platform`, pnpm |
| 86 | +can still resolve transitive packages like `@analogjs/vite-plugin-angular` and |
| 87 | +`@analogjs/vite-plugin-nitro` from npm instead of your local checkout. |
| 88 | +::: |
| 89 | + |
| 90 | +:::note |
| 91 | +pnpm currently does not allow `file:` entries in `catalog`, so local checkout |
| 92 | +wiring needs direct `file:` overrides instead of `catalog:` indirection. |
| 93 | +::: |
| 94 | + |
| 95 | +If your app also uses other published Analog packages such as |
| 96 | +`@analogjs/content` or `@analogjs/storybook-angular`, pin those the same way. |
| 97 | + |
| 98 | +### GitHub branch example |
| 99 | + |
| 100 | +If you want the same pattern from a GitHub branch instead of a local path, pnpm |
| 101 | +supports Git subdirectory specs via `#branch&path:...`. |
| 102 | + |
| 103 | +`pnpm-workspace.yaml` |
| 104 | + |
| 105 | +```yaml |
| 106 | +catalog: |
| 107 | + '@analogjs/platform': github:your-user/analog#your-branch&path:packages/platform/dist |
| 108 | + '@analogjs/router': github:your-user/analog#your-branch&path:packages/router/dist |
| 109 | + '@analogjs/vite-plugin-angular': github:your-user/analog#your-branch&path:packages/vite-plugin-angular/dist |
| 110 | + '@analogjs/vite-plugin-nitro': github:your-user/analog#your-branch&path:packages/vite-plugin-nitro/dist |
| 111 | + '@analogjs/vitest-angular': github:your-user/analog#your-branch&path:packages/vitest-angular/dist |
| 112 | +``` |
| 113 | + |
| 114 | +Root `package.json` |
| 115 | + |
| 116 | +```json |
| 117 | +{ |
| 118 | + "dependencies": { |
| 119 | + "@analogjs/platform": "catalog:" |
| 120 | + }, |
| 121 | + "overrides": { |
| 122 | + "@analogjs/platform": "$@analogjs/platform", |
| 123 | + "@analogjs/router": "$@analogjs/router", |
| 124 | + "@analogjs/vite-plugin-angular": "$@analogjs/vite-plugin-angular", |
| 125 | + "@analogjs/vite-plugin-nitro": "$@analogjs/vite-plugin-nitro", |
| 126 | + "@analogjs/vitest-angular": "$@analogjs/vitest-angular" |
| 127 | + } |
| 128 | +} |
| 129 | +``` |
| 130 | + |
| 131 | +:::caution |
| 132 | +For Analog, the GitHub form only works when the branch exposes release-ready |
| 133 | +`dist/package.json` files at those paths. Pointing pnpm at |
| 134 | +`path:packages/platform` or any other raw source package path will fail because |
| 135 | +those manifests still contain unresolved `catalog:` and `workspace:*` |
| 136 | +specifiers. |
| 137 | +::: |
| 138 | + |
| 139 | +## Notes |
| 140 | + |
| 141 | +- Use the repo root unless you have a specific reason to run inside a package subdirectory. |
| 142 | +- Prefer `pnpm nx <target>` when you want task-graph behavior that matches CI. |
| 143 | +- The scope names themselves are documented in the public guide so consumer and maintainer docs stay aligned. |
0 commit comments