Skip to content

Add monorepo export condition as alternative to source#2567

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-monorepo-export-support
Draft

Add monorepo export condition as alternative to source#2567
Copilot wants to merge 4 commits intomainfrom
copilot/add-monorepo-export-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Packages can now use monorepo instead of source for internal monorepo references. This prevents publishing dev-only export conditions to npm while maintaining type-safety and tooling support within the monorepo.

Changes

Validation

  • Requires publishConfig.exports when monorepo condition is present
  • Enforces pnpm as package manager (via packageManager field or parent package.json)
  • Made source field optional in PkgExport type to allow monorepo-only configs

Implementation

  • Added package-manager-detector for package manager validation with monorepo support
  • Made parseAndValidateExports async to enable package manager checks
  • Created getSourcePath() utility to abstract source/monorepo field access
  • Updated build, watch, and check tasks to handle both conditions

Example

{
  "packageManager": "pnpm@9.0.0",
  "exports": {
    ".": {
      "monorepo": "./src/index.ts",
      "default": "./dist/index.js"
    }
  },
  "publishConfig": {
    "exports": {
      ".": "./dist/index.js"
    }
  }
}

Existing packages using source continue to work unchanged.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

⚠️ No Changeset found

Latest commit: 9ce378e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI and others added 3 commits February 5, 2026 11:08
- Add package-manager-detector dependency
- Create detectPackageManager utility to detect and validate pnpm usage
- Update isPkgExport to accept either source or monorepo condition
- Make parseAndValidateExports async to validate package manager
- Add validation for monorepo condition requirements (publishConfig.exports and pnpm)
- Update all code references to support both source and monorepo paths
- Make source field optional in PkgExport type

Co-authored-by: stipsan <81981+stipsan@users.noreply.github.com>
- Add comprehensive tests for monorepo export condition validation
- Update all test functions to handle async parseAndValidateExports
- Fix parseTasks test to await parseAndValidateExports
- All 136 tests now passing

Co-authored-by: stipsan <81981+stipsan@users.noreply.github.com>
- Add explicit validation for regex match before using captured group
- Use shorthand property syntax for sourcePath assignments
- Improve code safety and readability

Co-authored-by: stipsan <81981+stipsan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for monorepo as export condition Add monorepo export condition as alternative to source Feb 5, 2026
Copilot AI requested a review from stipsan February 5, 2026 11:29
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.

2 participants