Migrate from npm to pnpm workspace #29

Closed
opened 2026-10-14 16:34:43 +00:00 by Syndria98 · 2 comments
Owner

Can you instead of using npm run dev for running all the monorepo can you use pnpm workspaces instead? Here you have a reference

https://pnpm.io/workspaces

Can you instead of using npm run dev for running all the monorepo can you use pnpm workspaces instead? Here you have a reference https://pnpm.io/workspaces
Syndria98 added the ai-ready label 2026-10-14 16:34:43 +00:00
Agent added the working label 2026-10-14 16:34:44 +00:00
Collaborator

Migration complete and verified. Here's what changed and why.

Workspace wiring

pnpm-workspace.yaml (new) — backend, frontend, discord-bot. pnpm 10 blocks dependency install scripts by default, so esbuild and @parcel/watcher are allowlisted (they place their native binaries through theirs; without them the Nuxt build is broken).

package.json (root) — added name/private, packageManager: "pnpm@10.28.2" for corepack, and switched the dev orchestration to workspace filtering, keeping concurrently (the Foundry launcher is not a package, and -k / names / colors stay as they were) plus one-shot helpers replacing npm --prefix X run dev:

pnpm dev            # backend + frontend + discord-bot + run-foundry.js
pnpm dev:backend | dev:frontend | dev:discord-bot
pnpm test

Lockfiles — the four package-lock.json files are gone, one pnpm-lock.yaml at the root. dragonroll-foundry/bridge deliberately stays out of the workspace (Node built-ins only, not part of pnpm dev, its README runs it standalone).

Images and CI

Docker builds now use the repository root as context (docker build -f ./<pkg>/Dockerfile . in deploy.yml) so the Dockerfiles can read the workspace manifests; each installs with corepack enable + pnpm install --frozen-lockfile [--prod] --filter ./<pkg>.... Backend/bot WORKDIR moves to …/<package> so dotenv's cwd-relative .env.production lookup is unchanged. Added a root .dockerignore (the per-package ones are no longer read once the context is the root); .env.production is kept, only .env is ignored. test.yml runs corepack pnpm test.

Companion fix that was required

A fresh resolution of the existing ^ ranges is unavoidable (npm lockfiles can't be converted), so the frontend now resolves Nuxt 4.6.1 / Vite 8, whose lightningcss minifier rejects RollWidgetDisplay.vue's nested > { font-size: 12px } — the scoped-style transform turned it into a dangling combinator. The old locked toolchain tolerated it. I rewrote it as .steps > * { font-size: 12px } (the author's evident intent, and it matches the sibling .steps :deep(.roll-val) rule). I confirmed with an npm install + npm run build baseline from HEAD that master built only because the old lockfile pinned the older toolchain — so this is version drift from the migration, not a pre-existing broken build. Heads-up: the new pnpm-lock.yaml therefore freezes those newer versions.

Tests

tests/pnpm-workspace.test.js (new, dependency-free like the other tests): workspace membership, root pinned/private, no npm lockfiles, pnpm dev filters every package and never calls npm, per-package dev:* scripts exist, the three Dockerfiles install from the lockfile via corepack with no npm ci/npm install fallback, the workflow builds from the root context, and the build-script allowlist.

Ran here: pnpm install, pnpm install --frozen-lockfile (root), pnpm test → 70 pass / 0 fail, pnpm --filter ./frontend run build → build complete, pnpm dev → all four prefixed commands launch and shut down cleanly (no orphaned dev server, port 3000 released), and the exact --frozen-lockfile --prod --filter install commands of the backend/bot Docker layers in scratch dirs with require('express'|'mongoose'|'discord.js') resolving afterwards. Not run: the Docker builds themselves — the daemon is not reachable in this environment.

Untouched on purpose: ecosystem.config.js (still the stale PM2 config from §9), README.md (points at install.sh/start.sh that do not exist — separate known problem), and the "Run with npm test" header comments in the five existing test files (those tests need no dependencies, so npm test still works there).

Migration complete and verified. Here's what changed and why. ## Workspace wiring **`pnpm-workspace.yaml`** (new) — `backend`, `frontend`, `discord-bot`. pnpm 10 blocks dependency install scripts by default, so `esbuild` and `@parcel/watcher` are allowlisted (they place their native binaries through theirs; without them the Nuxt build is broken). **`package.json`** (root) — added `name`/`private`, `packageManager: "pnpm@10.28.2"` for corepack, and switched the `dev` orchestration to workspace filtering, keeping `concurrently` (the Foundry launcher is not a package, and `-k` / names / colors stay as they were) plus one-shot helpers replacing `npm --prefix X run dev`: ``` pnpm dev # backend + frontend + discord-bot + run-foundry.js pnpm dev:backend | dev:frontend | dev:discord-bot pnpm test ``` **Lockfiles** — the four `package-lock.json` files are gone, one `pnpm-lock.yaml` at the root. `dragonroll-foundry/bridge` deliberately stays out of the workspace (Node built-ins only, not part of `pnpm dev`, its README runs it standalone). ## Images and CI Docker builds now use the **repository root as context** (`docker build -f ./<pkg>/Dockerfile .` in `deploy.yml`) so the Dockerfiles can read the workspace manifests; each installs with `corepack enable` + `pnpm install --frozen-lockfile [--prod] --filter ./<pkg>...`. Backend/bot `WORKDIR` moves to `…/<package>` so `dotenv`'s cwd-relative `.env.production` lookup is unchanged. Added a root `.dockerignore` (the per-package ones are no longer read once the context is the root); `.env.production` is kept, only `.env` is ignored. `test.yml` runs `corepack pnpm test`. ## Companion fix that was required A fresh resolution of the existing `^` ranges is unavoidable (npm lockfiles can't be converted), so the frontend now resolves Nuxt 4.6.1 / Vite 8, whose `lightningcss` minifier rejects `RollWidgetDisplay.vue`'s nested `> { font-size: 12px }` — the scoped-style transform turned it into a dangling combinator. The old locked toolchain tolerated it. I rewrote it as `.steps > * { font-size: 12px }` (the author's evident intent, and it matches the sibling `.steps :deep(.roll-val)` rule). I confirmed with an `npm install` + `npm run build` baseline from `HEAD` that master built only because the old lockfile pinned the older toolchain — so this is version drift from the migration, not a pre-existing broken build. Heads-up: the new `pnpm-lock.yaml` therefore freezes those newer versions. ## Tests `tests/pnpm-workspace.test.js` (new, dependency-free like the other tests): workspace membership, root pinned/private, no npm lockfiles, `pnpm dev` filters every package and never calls npm, per-package `dev:*` scripts exist, the three Dockerfiles install from the lockfile via corepack with no `npm ci`/`npm install` fallback, the workflow builds from the root context, and the build-script allowlist. Ran here: `pnpm install`, `pnpm install --frozen-lockfile` (root), `pnpm test` → **70 pass / 0 fail**, `pnpm --filter ./frontend run build` → build complete, `pnpm dev` → all four prefixed commands launch and shut down cleanly (no orphaned dev server, port 3000 released), and the exact `--frozen-lockfile --prod --filter` install commands of the backend/bot Docker layers in scratch dirs with `require('express'|'mongoose'|'discord.js')` resolving afterwards. **Not** run: the Docker builds themselves — the daemon is not reachable in this environment. Untouched on purpose: `ecosystem.config.js` (still the stale PM2 config from §9), `README.md` (points at `install.sh`/`start.sh` that do not exist — separate known problem), and the "Run with `npm test`" header comments in the five existing test files (those tests need no dependencies, so `npm test` still works there).
Collaborator

Implementation is ready for review: #31

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/31
Agent added help wanted and removed working labels 2026-10-14 17:01:03 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#29