Skip to content

fix: handle modern package.json workspace formats#228

Open
MrChrisRodriguez wants to merge 1 commit intodmno-dev:mainfrom
MrChrisRodriguez:fix-modern-workspace-format
Open

fix: handle modern package.json workspace formats#228
MrChrisRodriguez wants to merge 1 commit intodmno-dev:mainfrom
MrChrisRodriguez:fix-modern-workspace-format

Conversation

@MrChrisRodriguez
Copy link

Handle both legacy format (workspaces as array) and modern (workspaces as object with packages property) formats within package.json.

Example:

  "workspaces": {
    "packages": ["apps/*", "libs/*", "growth/*"],  // <-- this
    "catalog": {
      "@cloudflare/workers-types": "^4.20250619.0",
      // ... other dependency versions
    }
  }
}

Handle both legacy format (workspaces as array) and modern (workspaces as object with packages property) formats
Copy link
Member

@theoephraim theoephraim left a comment

Choose a reason for hiding this comment

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

This looks great. I added a small suggestion just to use lodash utils, mostly just to match the style of the rest of the codebase...

Do you know which package managers support this? Digging through docs, it's not mentioned anywhere:

The only place I found it was here - https://bun.com/docs/install/catalogs#1-define-catalogs-in-root-package-json

I hope the other package managers adopt it too - using catalogs (via pnpm) has been great :)

isMonorepo = true;
// Handle both legacy format (workspaces as array) and modern format (workspaces as object with packages property)
let actualPackagePatterns: string[] | undefined;
if (Array.isArray(possiblePackagePatterns)) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (Array.isArray(possiblePackagePatterns)) {
if (_.isArray(possiblePackagePatterns)) {

let actualPackagePatterns: string[] | undefined;
if (Array.isArray(possiblePackagePatterns)) {
actualPackagePatterns = possiblePackagePatterns;
} else if (possiblePackagePatterns && typeof possiblePackagePatterns === 'object' && possiblePackagePatterns.packages) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} else if (possiblePackagePatterns && typeof possiblePackagePatterns === 'object' && possiblePackagePatterns.packages) {
} else if (_.isObject(possiblePackagePatterns) && _.isArray(possiblePackagePatterns.packages)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants