|
| 1 | +--- |
| 2 | +status: complete |
| 3 | +created: '2025-11-18' |
| 4 | +tags: |
| 5 | + - packaging |
| 6 | + - bug-fix |
| 7 | +priority: high |
| 8 | +created_at: '2025-11-18T09:26:38.346Z' |
| 9 | +updated_at: '2025-11-18T09:28:17.735Z' |
| 10 | +transitions: |
| 11 | + - status: in-progress |
| 12 | + at: '2025-11-18T09:27:10.441Z' |
| 13 | + - status: complete |
| 14 | + at: '2025-11-18T09:28:17.735Z' |
| 15 | +completed_at: '2025-11-18T09:28:17.735Z' |
| 16 | +completed: '2025-11-18' |
| 17 | +--- |
| 18 | + |
| 19 | +# Fix @leanspec/ui standalone packaging issue |
| 20 | + |
| 21 | +> **Status**: ✅ Complete · **Priority**: High · **Created**: 2025-11-18 · **Tags**: packaging, bug-fix |
| 22 | +
|
| 23 | +**Project**: lean-spec |
| 24 | +**Team**: Core Development |
| 25 | + |
| 26 | +## Overview |
| 27 | + |
| 28 | +The published `@leanspec/[email protected]` package fails to run with error `Cannot find module 'next'`. This occurs because Next.js standalone build creates symlinks in `node_modules/`, but npm pack doesn't follow symlinks by default, resulting in missing dependencies in the published package. |
| 29 | + |
| 30 | +**Root Cause**: The `files` field in `package.json` included `.next/standalone/node_modules/` which only contains symlinks pointing to `.next/standalone/node_modules/.pnpm/`. When npm packs the tarball, these symlinks aren't resolved. |
| 31 | + |
| 32 | +**Impact**: Users running `lean-spec ui` via the published npm package cannot start the UI server. |
| 33 | + |
| 34 | +## Design |
| 35 | + |
| 36 | +**Solution**: Update the `files` field in `packages/ui/package.json` to include the actual pnpm store location: |
| 37 | + |
| 38 | +```json |
| 39 | +"files": [ |
| 40 | + "bin/", |
| 41 | + ".next/standalone/packages/", |
| 42 | + ".next/standalone/node_modules/.pnpm/", // Changed from .next/standalone/node_modules/ |
| 43 | + ".next/static/", |
| 44 | + "public/", |
| 45 | + "README.md", |
| 46 | + "LICENSE" |
| 47 | +] |
| 48 | +``` |
| 49 | + |
| 50 | +This ensures actual dependency files (not just symlinks) are included in the published package. |
| 51 | + |
| 52 | +**Version Alignment**: All packages bumped to `0.2.5`: |
| 53 | +- `@leanspec/ui`: 0.2.4 → 0.2.5 |
| 54 | +- `@leanspec/core`: 0.2.4 → 0.2.5 |
| 55 | +- `lean-spec`: 0.2.4 → 0.2.5 |
| 56 | +- `@leanspec/mcp`: Already at 0.2.5 |
| 57 | + |
| 58 | +## Plan |
| 59 | + |
| 60 | +- [x] Update `packages/ui/package.json` files field |
| 61 | +- [x] Bump all package versions to 0.2.5 |
| 62 | +- [x] Update cross-package dependencies |
| 63 | +- [ ] Build and test locally |
| 64 | +- [ ] Publish updated packages |
| 65 | + |
| 66 | +## Test |
| 67 | + |
| 68 | +**Verification Steps**: |
| 69 | +1. Build the UI package: `pnpm --filter @leanspec/ui build` |
| 70 | +2. Pack locally: `npm pack --dry-run` and verify `next` module is included |
| 71 | +3. Test installation in separate directory: |
| 72 | + ```bash |
| 73 | + cd /tmp/test-leanspec-ui |
| 74 | + npm install @leanspec/ [email protected] |
| 75 | + npx leanspec-ui --specs /path/to/specs |
| 76 | + ``` |
| 77 | +4. Verify UI starts without "Cannot find module 'next'" error |
| 78 | + |
| 79 | +## Notes |
| 80 | + |
| 81 | +**Package Size**: With this change, the published package is ~18.3 MB compressed (65 MB unpacked), which is reasonable for a Next.js standalone app. |
| 82 | + |
| 83 | +**Future Improvement**: Consider documenting version alignment strategy in CONTRIBUTING.md or creating a release script to ensure versions stay in sync. |
0 commit comments