Skip to content

Add Turborepo monorepo configuration with pnpm workspaces#862

Open
gregnazario wants to merge 7 commits intomainfrom
cursor/turborepo-monorepo-structure-2bbb
Open

Add Turborepo monorepo configuration with pnpm workspaces#862
gregnazario wants to merge 7 commits intomainfrom
cursor/turborepo-monorepo-structure-2bbb

Conversation

@gregnazario
Copy link
Collaborator

@gregnazario gregnazario commented Mar 21, 2026

Description

Sets up Turborepo for monorepo orchestration so that multiple apps and packages can be easily organized in this repository.

What's included:

  • turbo.json — Task pipeline configuration for build, test, lint, check, fmt, and dev tasks. Root tasks use the //#task syntax with scoped inputs for efficient caching. Workspace package builds depend on ^build plus the root SDK build (//#build) to ensure correct ordering.
  • pnpm-workspace.yaml — Workspace package definitions covering packages/*, apps/*, confidential-assets, examples/*, and projects/*.
  • packages/ and apps/ directories — Scaffolded with .gitkeep for adding new workspace packages and applications.
  • Workspace-wide turbo scriptsbuild:all, test:all, lint:all, check:all, fmt:all added to root package.json (filtered to core packages only).
  • All sub-packages wired as workspace membersconfidential-assets, examples/*, and projects/* use workspace:* protocol for the @aptos-labs/ts-sdk dependency; pnpm overrides consolidated at root; all stale nested lockfiles removed.
  • CI updatedrun-confidential-assets-tests action now builds the root SDK before running tests (required since workspace:* resolves to the local unbuilt root instead of the pre-built npm package).
  • Confidential-assets test funding fix — Increased test account funding from 1 APT to 10 APT to prevent INSUFFICIENT_BALANCE_FOR_TRANSACTION_FEE failures after the default maxGasAmount increase to 2,000,000.
  • .turbo added to .gitignore
  • Documentation updatedAGENTS.md, CLAUDE.md, and CHANGELOG.md updated with monorepo structure and new commands.

All existing SDK commands (pnpm build, pnpm test, pnpm check, etc.) continue to work unchanged.

Test Plan

  • pnpm install correctly resolves all workspace dependencies (9 workspace projects)
  • turbo run build --dry shows correct dependency ordering (//#build → dependent packages)
  • pnpm build:all succeeds: root SDK and confidential-assets build (2 successful, examples/projects excluded via filter)
  • pnpm build still works standalone for the SDK
  • pnpm check:all runs biome checks across core workspace packages
  • pnpm check passes (241 files, no issues)
  • Playwright binary is correctly accessible in examples/web-test/node_modules/.bin/ after workspace install
  • CI run-confidential-assets-tests action builds SDK before tests so Vite can resolve @aptos-labs/ts-sdk entry

Review feedback addressed

  • Removed all stale nested lockfiles (pnpm-lock.yaml in examples/*, projects/gas-station, and bun.lock in examples/bun-test)
  • Moved @aptos-labs/ts-sdk from devDependencies to dependencies in projects/gas-station since it's imported at runtime
  • Removed redundant peerDependencies from projects/gas-station (it's a demo app, not a published library)
  • Increased confidential-assets test funding from 1 APT to 10 APT to fix INSUFFICIENT_BALANCE_FOR_TRANSACTION_FEE
  • Re: turbo.json //#build comment — this is correct Turborepo v2 root task syntax; //#build maps to the root package.json's build script and is properly defined in turbo.json

Related Links

N/A

Checklist

  • Have you ran pnpm fmt?
  • Have you updated the CHANGELOG.md?
Open in Web Open in Cursor 

cursoragent and others added 2 commits March 21, 2026 04:58
- Add turbo.json with task pipeline configuration for build, test, lint, check, fmt, and dev tasks
- Add pnpm-workspace.yaml defining workspace packages (packages/*, apps/*, confidential-assets)
- Create packages/ and apps/ directories for organizing new workspace packages and applications
- Install turbo ^2.8.20 as a devDependency
- Add workspace-wide turbo scripts: build:all, test:all, lint:all, check:all, fmt:all
- Wire up confidential-assets as a workspace member using workspace:* protocol
- Merge confidential-assets pnpm overrides into root package.json (workspace-level only)
- Remove confidential-assets separate pnpm-lock.yaml (now managed by root workspace install)
- Add .turbo to .gitignore
- Add onlyBuiltDependencies for @swc/core and esbuild
- Update AGENTS.md and CLAUDE.md with monorepo structure and turbo commands
- Update CHANGELOG.md with Turborepo setup entry

Co-authored-by: Greg Nazario <greg@gnazar.io>
- Add examples/* and projects/* to pnpm-workspace.yaml so pnpm install
  correctly resolves their dependencies (fixes run-web-tests CI failure
  where playwright was not found after workspace detection)
- Update all example/project SDK dependencies from link:../.. or file:../..
  to workspace:* protocol
- Merge projects/gas-station pnpm overrides into root package.json
- Filter turbo workspace scripts (build:all, test:all, etc.) to only run
  on core packages (root SDK, packages/*, confidential-assets), excluding
  examples and projects which have standalone build/test workflows
- Update AGENTS.md and CLAUDE.md documentation

Co-authored-by: Greg Nazario <greg@gnazar.io>
The confidential-assets tests now resolve @aptos-labs/ts-sdk via workspace:*
which points to the local root package. Vite needs the built dist/ to resolve
the entry point. Previously this worked because the separate pnpm install
pulled the pre-built package from npm.

- Replace redundant 'cd confidential-assets && pnpm install' with 'pnpm build'
- Root pnpm install already handles workspace member dependencies

Co-authored-by: Greg Nazario <greg@gnazar.io>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Turborepo + pnpm-workspaces monorepo setup for the Aptos TypeScript SDK repo, enabling orchestrated build/test/lint/check/fmt workflows across the root SDK and additional workspace members.

Changes:

  • Add turbo.json task pipeline config and pnpm-workspace.yaml workspace definitions.
  • Wire workspace members to depend on the root SDK via workspace:* and consolidate pnpm overrides at the root.
  • Add repo-wide *:all scripts and update docs/changelog + ignore .turbo.

Reviewed changes

Copilot reviewed 15 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
turbo.json Defines Turborepo task graph (build/test/lint/check/fmt/dev) and root-task inputs/outputs.
pnpm-workspace.yaml Declares workspace package globs for packages/apps/examples/projects/confidential-assets.
package.json Adds turbo + build:all/test:all/lint:all/check:all/fmt:all scripts; consolidates pnpm overrides.
confidential-assets/package.json Adds @aptos-labs/ts-sdk as workspace:* devDependency; removes per-package pnpm overrides.
projects/gas-station/package.json Switches to workspace:* for the SDK and removes per-package pnpm overrides.
examples/web-test/package.json Switches SDK dependency from link to workspace:*.
examples/typescript/package.json Switches SDK dependency from link to workspace:*.
examples/typescript-esm/package.json Switches SDK dependency from link to workspace:*.
examples/javascript/package.json Switches SDK dependency from link to workspace:*.
examples/deno-test/package.json Switches SDK dependency from file to workspace:*.
examples/bun-test/package.json Switches SDK dependency from file to workspace:*.
confidential-assets/pnpm-lock.yaml Removes nested lockfile in favor of the workspace root lockfile.
.gitignore Ignores Turborepo state directory (.turbo).
AGENTS.md Documents new monorepo layout and turbo commands.
CLAUDE.md Documents new monorepo structure and turbo commands.
CHANGELOG.md Adds entries describing the monorepo/turbo setup.
packages/.gitkeep Scaffolds packages/ directory.
apps/.gitkeep Scaffolds apps/ directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 22 to 32
"devDependencies": {
"@aptos-labs/ts-sdk": "workspace:*",
"@types/express": "^5.0.6",
"@types/node": "^22.19.13",
"tsx": "^4.21.0",
"tsup": "^8.5.1",
"typescript": "^5.9.3"
},
"peerDependencies": {
"@aptos-labs/ts-sdk": "^5.2.1 || ^6.1.0"
},
"pnpm": {
"overrides": {
"minimatch@^9": "^9.0.7",
"qs@^6": "^6.14.1",
"glob@^10": "^10.5.0",
"rollup@^4": "^4.59.0"
}
}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aptos-labs/ts-sdk is imported at runtime by this project (e.g. in src/server.ts), so it should be listed under dependencies rather than devDependencies. Keeping it as a devDependency can break production installs that omit devDependencies.

Copilot uses AI. Check for mistakes.
Comment on lines 20 to 32
"express": "^5.2.1"
},
"devDependencies": {
"@aptos-labs/ts-sdk": "workspace:*",
"@types/express": "^5.0.6",
"@types/node": "^22.19.13",
"tsx": "^4.21.0",
"tsup": "^8.5.1",
"typescript": "^5.9.3"
},
"peerDependencies": {
"@aptos-labs/ts-sdk": "^5.2.1 || ^6.1.0"
},
"pnpm": {
"overrides": {
"minimatch@^9": "^9.0.7",
"qs@^6": "^6.14.1",
"glob@^10": "^10.5.0",
"rollup@^4": "^4.59.0"
}
}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this project is a pnpm workspace member and uses workspace:*, the existing projects/gas-station/pnpm-lock.yaml is stale (it still pins @aptos-labs/ts-sdk differently). Consider removing the nested lockfile and relying on the workspace root pnpm-lock.yaml to avoid confusion and accidental drift.

Copilot uses AI. Check for mistakes.
},
"dependencies": {
"@aptos-labs/ts-sdk": "link:../.."
"@aptos-labs/ts-sdk": "workspace:*"
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package now depends on @aptos-labs/ts-sdk via workspace:*, but examples/web-test/pnpm-lock.yaml still references the old link:../.. specifier. In a workspace setup, it’s better to remove the per-package lockfile (and rely on the root pnpm-lock.yaml) or regenerate it to match the new dependency spec.

Suggested change
"@aptos-labs/ts-sdk": "workspace:*"
"@aptos-labs/ts-sdk": "link:../.."

Copilot uses AI. Check for mistakes.
"author": "",
"dependencies": {
"@aptos-labs/ts-sdk": "link:../..",
"@aptos-labs/ts-sdk": "workspace:*",
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package now depends on @aptos-labs/ts-sdk via workspace:*, but examples/typescript/pnpm-lock.yaml still references the old link:../.. specifier. In a workspace setup, it’s better to remove the per-package lockfile (and rely on the root pnpm-lock.yaml) or regenerate it to match the new dependency spec.

Suggested change
"@aptos-labs/ts-sdk": "workspace:*",
"@aptos-labs/ts-sdk": "link:../..",

Copilot uses AI. Check for mistakes.
Comment on lines 24 to 29
"keywords": [],
"author": "",
"dependencies": {
"@aptos-labs/ts-sdk": "link:../..",
"@aptos-labs/ts-sdk": "workspace:*",
"@noble/hashes": "^1.7.2",
"dotenv": "17.3.1",
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package now depends on @aptos-labs/ts-sdk via workspace:*, but examples/typescript-esm/pnpm-lock.yaml still references the old link:../.. specifier. In a workspace setup, it’s better to remove the per-package lockfile (and rely on the root pnpm-lock.yaml) or regenerate it to match the new dependency spec.

Copilot uses AI. Check for mistakes.
Comment on lines 16 to 21
"keywords": [],
"author": "",
"dependencies": {
"@aptos-labs/ts-sdk": "link:../..",
"@aptos-labs/ts-sdk": "workspace:*",
"npm-run-all2": "8.0.4"
}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package now depends on @aptos-labs/ts-sdk via workspace:*, but examples/javascript/pnpm-lock.yaml still references the old link:../.. specifier. In a workspace setup, it’s better to remove the per-package lockfile (and rely on the root pnpm-lock.yaml) or regenerate it to match the new dependency spec.

Copilot uses AI. Check for mistakes.
},
"dependencies": {
"@aptos-labs/ts-sdk": "file:../.."
"@aptos-labs/ts-sdk": "workspace:*"
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package now depends on @aptos-labs/ts-sdk via workspace:*, but examples/bun-test/bun.lock still pins @aptos-labs/ts-sdk as file:../... Either update/regenerate the Bun lockfile to match the new specifier, or consider removing it if pnpm is the source of truth for installs in this monorepo.

Suggested change
"@aptos-labs/ts-sdk": "workspace:*"
"@aptos-labs/ts-sdk": "file:../.."

Copilot uses AI. Check for mistakes.
cursoragent and others added 3 commits March 21, 2026 05:17
Now that all sub-packages are pnpm workspace members, the root
pnpm-lock.yaml is the single source of truth for dependency resolution.
Remove the per-package lockfiles that referenced the old link:/file:
specifiers.

Co-authored-by: Greg Nazario <greg@gnazar.io>
The SDK is imported at runtime in server.ts and client.ts, so it
belongs in dependencies rather than devDependencies to avoid breaking
production installs that omit devDependencies.

Co-authored-by: Greg Nazario <greg@gnazar.io>
The default maxGasAmount was increased to 2,000,000 in SDK 6.2.0, which
at 100 octas/gas reserves 2 APT for fees. The tests were funding accounts
with only 1 APT (100,000,000 octas), causing INSUFFICIENT_BALANCE_FOR_
TRANSACTION_FEE errors. Increase to 10 APT (1,000,000,000 octas) to
match the main SDK test conventions.

Co-authored-by: Greg Nazario <greg@gnazar.io>
@gregnazario gregnazario marked this pull request as ready for review March 21, 2026 05:36
@gregnazario gregnazario requested a review from a team as a code owner March 21, 2026 05:36
@gregnazario gregnazario requested a review from Copilot March 21, 2026 05:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 32 changed files in this pull request and generated 2 comments.

Files not reviewed (5)
  • examples/javascript/pnpm-lock.yaml: Language not supported
  • examples/typescript-esm/pnpm-lock.yaml: Language not supported
  • examples/typescript/pnpm-lock.yaml: Language not supported
  • examples/web-test/pnpm-lock.yaml: Language not supported
  • projects/gas-station/pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4 to +10
"build": {
"dependsOn": ["^build", "//#build"],
"outputs": ["dist/**"]
},
"//#build": {
"inputs": ["src/**", "tsup.config.ts", "tsconfig.json", "package.json"],
"outputs": ["dist/**"]
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build.dependsOn references "//#build", but no workspace package defines a //#build script (root package.json only has build, not //#build). This makes the task graph inconsistent and can cause turbo run build/pnpm build:all to fail or silently skip the intended root build step. Either remove "//#build" and rely on ^build (since workspace deps already enforce ordering), or add corresponding //#build (and other //#*) scripts in the root package.json and wire test/lint/check to depend on them as intended.

Copilot uses AI. Check for mistakes.
Comment on lines 29 to 31
},
"peerDependencies": {
"@aptos-labs/ts-sdk": "^5.2.1 || ^6.1.0"
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aptos-labs/ts-sdk is declared in both dependencies and peerDependencies. For an app/package that is meant to be run directly (not consumed as a library), keeping it as a peer dependency is unnecessary and will trigger peer-dependency warnings for consumers/installers. Consider removing the peerDependencies entry here (or, if this is intended to be a published library, keep it as a peer dependency and move/remove the direct dependencies entry accordingly).

Suggested change
},
"peerDependencies": {
"@aptos-labs/ts-sdk": "^5.2.1 || ^6.1.0"

Copilot uses AI. Check for mistakes.
gas-station is a demo app, not a published library. The SDK is already
in dependencies via workspace:*, so the peerDependencies entry is
unnecessary and would only trigger warnings.

Co-authored-by: Greg Nazario <greg@gnazar.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants