Skip to content

feat: monorepo setup — npm workspaces scaffolding for package split #489

@RobertLD

Description

@RobertLD

Summary

Prerequisite for #488. Convert the libscope repo to an npm workspaces monorepo so that sub-packages can be developed, built, and published independently from a single repository.

Problem / Motivation

Before any individual package can be extracted (#488), the repo needs the workspaces infrastructure in place. Without it, cross-package imports won't resolve during development and CI won't know how to build each package independently.

Proposed Solution

  • Add an npm workspaces config to the root package.json pointing at each packages/* directory
  • Create a packages/ directory and stub out a package.json for each planned sub-package
  • Set up a root-level tsconfig.json with project references so tsc can build packages in dependency order
  • Configure CI to run lint, typecheck, test, and build across all workspaces
  • Shared dev tooling (eslint, prettier, vitest config) stays at the root and is inherited by packages

Acceptance Criteria

  • Root package.json has a workspaces field covering all packages/* entries
  • npm install from the root installs all workspace dependencies and symlinks cross-package deps correctly
  • Each sub-package has a stub package.json with correct name, main, types, and exports fields
  • npm run build from the root builds all packages in dependency order without errors
  • CI runs lint, typecheck, test, and build for each workspace on Node 20 and 22
  • Existing libscope CLI and all current tests continue to pass unchanged

Out of Scope

  • Actually moving code into packages — that happens in the individual package extraction issues
  • Changing any public API surface
  • Turborepo or other build orchestration beyond npm workspaces (can be added later if build times warrant it)

Technical Notes

  • npm workspaces requires npm ≥7 / Node ≥15; CI already runs Node 20+, so no constraint there
  • TypeScript project references (composite: true, references: [] in tsconfig) will be needed per package for incremental builds
  • The existing root tsconfig.json should become the base config; each package extends it

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestrefactorCode refactoring

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions