{"_id":"@bimo-dk/nexus-build","name":"@bimo-dk/nexus-build","dist-tags":{"latest":"0.2.1"},"versions":{"0.2.1":{"name":"@bimo-dk/nexus-build","version":"0.2.1","description":"Auto-generate Native Federation config from @NexusRemote class decorators","license":"MIT","repository":{"type":"git","url":"git+https://github.com/Bimo-dk/nexus-packages.git","directory":"packages/build"},"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./scanner":{"types":"./dist/scanner.d.ts","import":"./dist/scanner.mjs","require":"./dist/scanner.cjs"},"./vite":{"types":"./dist/vite-plugin.d.ts","import":"./dist/vite-plugin.mjs","require":"./dist/vite-plugin.cjs"}},"bin":{"nexus-build":"dist/cli.cjs"},"sideEffects":false,"scripts":{"build":"tsup","test":"vitest run --passWithNoTests","lint":"echo \"(skipping lint — no eslint config yet)\" && exit 0","type-check":"tsc --noEmit","clean":"rimraf dist"},"dependencies":{"@bimo-dk/nexus-core":"*","chalk":"^5.3.0","commander":"^12.1.0","typescript":"^5.6.3"},"devDependencies":{"@types/node":"^22.10.0","rimraf":"^6.0.1","tsup":"^8.3.5","vite":"^5.0.0","vitest":"^2.1.8"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"engines":{"node":">=22.0.0"},"_id":"@bimo-dk/nexus-build@0.2.1","gitHead":"29013b61c134b7200bf24d9548d93c50f42afd36","bugs":{"url":"https://github.com/Bimo-dk/nexus-packages/issues"},"homepage":"https://github.com/Bimo-dk/nexus-packages#readme","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-iOYK1yehT6pPzaIVZq1fUOU/7mCveWT/GFcQrZoqYxP5sizp3y+1+5DP3qlXoc7VN7lhlX5y4z7TzxDj/Z2qHQ==","shasum":"bfee44d04d194dfc6f1237f6160d9eda9f4edf52","tarball":"https://registry.npmjs.org/@bimo-dk/nexus-build/-/nexus-build-0.2.1.tgz","fileCount":30,"unpackedSize":228979,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH183LmRgi5AzQgI4RNv4ly2QyFUn0eWBcso8CMU8KgoAiAxcrr8ebdtvyuv9vSmKQcVGPNzqyewdMvA/Q9M/SRUew=="}]},"_npmUser":{"name":"svp_bimo","email":"svp@bimo.dk"},"directories":{},"maintainers":[{"name":"svp_bimo","email":"svp@bimo.dk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nexus-build_0.2.1_1780727148333_0.9819042630091519"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-06T06:25:48.154Z","0.2.1":"2026-06-06T06:25:48.477Z","modified":"2026-06-06T06:25:48.720Z"},"maintainers":[{"name":"svp_bimo","email":"svp@bimo.dk"}],"description":"Auto-generate Native Federation config from @NexusRemote class decorators","homepage":"https://github.com/Bimo-dk/nexus-packages#readme","repository":{"type":"git","url":"git+https://github.com/Bimo-dk/nexus-packages.git","directory":"packages/build"},"bugs":{"url":"https://github.com/Bimo-dk/nexus-packages/issues"},"license":"MIT","readme":"# @bimo-dk/nexus-build\n\nAuto-generate Native Federation config from `@NexusRemote` class decorators. No more hand-editing `federation.config.json` — annotate one component and `nexus-build` figures out the rest.\n\n## Installation\n\n```bash\nnpm install -D @bimo-dk/nexus-build\n```\n\n## Usage (the only two changes you need)\n\n### 1. Annotate your entry component\n\n```typescript\n// src/app/remote-entry/entry.component.ts\nimport { Component } from '@angular/core';\nimport { NexusRemote } from '@bimo-dk/nexus-build';\n\n@NexusRemote()\n@Component({\n  selector: 'app-checkout',\n  template: `<h1>Checkout</h1>`,\n})\nexport default class CheckoutComponent {}\n```\n\nThat's it. No `name`, no `route`, no `exposes` block.\n\n### 2. Run `nexus-build` before your Angular build\n\n```jsonc\n// package.json\n{\n  \"scripts\": {\n    \"prebuild\": \"nexus-build\",\n    \"build\": \"ng build\"\n  }\n}\n```\n\nWhen you `npm run build`, `nexus-build` scans `src/**/*.ts`, finds `@NexusRemote`, and writes:\n\n```json\n{\n  \"name\": \"checkout\",\n  \"exposes\": {\n    \"./RemoteEntry\": \"./src/app/remote-entry/entry.component.ts\"\n  },\n  \"shared\": { \"@angular/core\": { \"singleton\": true, ... } }\n}\n```\n\n## How auto-detection works\n\nWhen you write `@NexusRemote()` without arguments, the name is resolved in this order:\n\n1. **Explicit option** — `@NexusRemote({ name: 'checkout' })` always wins.\n2. **`package.json#name`** — if it matches camelCase (e.g. `\"name\": \"checkout\"`, or the unscoped tail of `@bimo-dk/checkout`).\n3. **Class name** — `CheckoutComponent` → strip `Component`/`Entry` suffix → camelCase → `checkout`.\n\nThe route is derived from the name by converting camelCase to kebab-case (`checkoutPage` → `checkout-page`), unless you set `route` explicitly.\n\n## Decorator options (all optional)\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `name` | `string` | inferred | Remote name (camelCase) |\n| `route` | `string` | inferred from `name` | Route path under the host shell (kebab-case) |\n| `exposeAs` | `string` | `'RemoteEntry'` | Module name in the `exposes` block |\n\n## CLI\n\n```bash\nnexus-build                  # scan + write federation.config.json\nnexus-build --dry-run        # print resolved config without writing\nnexus-build scan             # list discovered remotes as JSON (no write)\nnexus-build --root ./apps/checkout --src src\n```\n\n## Programmatic API\n\n```typescript\nimport { scanForRemotes, writeFederationConfig } from '@bimo-dk/nexus-build';\n\nconst remotes = await scanForRemotes({ projectRoot: process.cwd() });\nconst result = await writeFederationConfig(remotes, process.cwd(), {\n  shared: { '@angular/core': { singleton: true, requiredVersion: 'auto' } },\n});\nconsole.log(result.config);\n```\n\n## How it fits into the Nexus build pipeline\n\n```\nng build\n  ├─ prebuild (npm-script)\n  │    └─ nexus-build\n  │         ├─ scan src/**/*.ts for @NexusRemote\n  │         ├─ resolve name/route/exposeAs\n  │         └─ write federation.config.json\n  └─ ng build (reads federation.config.js -> federation.config.json)\n```\n\n`federation.config.js` stays as-is — it's Native Federation library convention. It just reads the JSON that `nexus-build` regenerates.\n\n## Conflict handling\n\n- **Same exposeAs from two files** -> error. Set distinct `exposeAs` values to disambiguate.\n- **Two decorators with different names but same exposeAs** -> error. Pick one name.\n- **`shared` block already in federation.config.json** -> preserved (not overwritten) unless you pass a `shared` override.\n","readmeFilename":"README.md","_rev":"1-0d36eb930b5de47a91705007519907de"}