What this thread does
Do first: inspect the app's manifest dependency and the shared package's exports targets before adding TypeScript aliases.
Short answer
As of November 2026, this recipe pins pnpm 10.33.0 and, when using a task cache, Turborepo 2.11.10. Compile shared packages and declarations before apps consume their exported files, and include those artifacts in cache outputs.
Choose / don't choose
- Compiled shared package: choose when apps have different transpilation/runtime support or distribution needs; don't point Node consumers at TypeScript source without an explicit loader contract (internal packages).
- Source exports: choose only when every consuming tool can transpile that source; don't assume editor resolution establishes production loading.
- pnpm recursive build: choose for topological script ordering without a task cache; don't combine artifact-dependent builds with
--parallelor--no-sort(run, recursive). - Turborepo: choose when cache restoration is needed; don't leave build dependencies or outputs implicit (task configuration).
Not for: renaming a pnpm package; see pnpm-monorepo-rename-shared-package-update-all-imports.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
dependencies workspace reference | "@acme/shared": "workspace:*" in app; producer name must match and workspace globs must include it | pnpm 10.33.0 | workspace protocol |
tasks.build.dependsOn | ["^build"] builds direct dependency tasks before each consumer | Turborepo 2.11.10 | tasks |
tasks.build.outputs | ["dist/**"] for JS and declarations emitted into dist; include any other actual output directories | Turborepo 2.11.10 | tasks |
compilerOptions.composite, declaration | Both true for TypeScript project-reference producers | Locked TypeScript | project references |
compilerOptions.rootDir, outDir | src and dist for this authored layout | Locked TypeScript | compiler options |
exports["."] | Expose the built public entry point for this ESM-only producer; set type: "module" | Node consumer | package entries |
--workspace-concurrency | Default 4; retain dependency sorting while tuning parallel independent packages | pnpm 10.33.0 | recursive |
For pnpm, give every compiled package a build script. With TypeScript references, tsc -b orders those explicitly referenced projects; Declaration generation belongs inside the producer's build, before consumers.
Order of operations
1. Include app/package folders in pnpm-workspace.yaml, declare real manifest dependencies, and install the workspace from the lockfile. (workspaces). 2. Compile shared JS and declarations in one producer build; expose only emitted public files. Ensure every exports target exists, including subpaths (Node subpaths). 3. Choose one graph owner: run pnpm --filter '@acme/app...' --workspace-concurrency=4 run build for the app plus dependencies, or pnpm exec turbo run build with the table's dependencies/outputs. For all packages without Turbo, pnpm -r run build sorts dependencies first (filters). 4. Perform the app's real production import/build from a clean checkout after producer compilation. Repeat with a warm task cache and absent emitted artifacts: a cache hit should restore dist before the app loads it. Inspect logs and all JS/declaration targets rather than relying on an editor import. 5. If publishing, inspect pnpm pack output and confirm compiled files are included; workspace ranges are rewritten at packing (publishing).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
ERR_PACKAGE_PATH_NOT_EXPORTED | App deep-imports an unlisted private path | Use the public barrel or intentionally export that subpath and compile its target | Node subpaths |
will not restore any file outputs | Turbo hit contains logs but emitted files were not declared in outputs | Set build outputs to actual artifact globs, then populate the cache with a successful producer build | task outputs |
If the exported path is allowed but its file is absent, inspect producer build order and dist contents before changing resolution. Gi11i4m's pnpm #7131, September 25, 2023 reports discovering recursive dependency ordering and its interaction with filtering; it is usage evidence, not a cache benchmark.
Missing
- App-specific transpiler support, package output layout and cache input/environment policy are not established. Dual ESM/CJS publishing and native addons need separate consumer contracts.
Checked
2026-11-12; Sources read: releases, pnpm workspace/filter/run/recursive guides, TypeScript references/options, Node package exports, Turbo internal-package/task docs and Gi11i4m's report. No installs, builds or cache operations were run.
Started from a post by @pnpm, packaged by the editor. Original post