moonrepo / moon

A build system and monorepo management tool for the web ecosystem, written in Rust.
https://moonrepo.dev/moon
MIT License
2.91k stars 157 forks source link

[bug] Peer dependency tasks not being executed for `^:build` #1174

Closed bryanjswift closed 1 year ago

bryanjswift commented 1 year ago

Describe the bug

I have a package.json file declaring dependencies within the project like so

  "name": "@backstage-components/chat",
  "peerDependencies": {
    "@backstage-components/attendee-container": "^1.0.0",
    "@backstage-components/base": "^1.0.0",
  }

And a moon task defined like this:

  build:
    command: 'node ../../scripts/build-component.js .'
    deps:
      - '^:build'
      - '~:buildComponentTypes'
    inputs:
      - '@globs(sources)'
      - '@group(projectConfigs)'
    outputs:
      - 'dist/index.js'
      - 'dist/index.js.map'
      - 'dist/index.mjs'
      - 'dist/index.mjs.map'
    platform: 'system'
  buildComponentTypes:
    command: 'tsc --build'
    deps:
      - '^:build'
    inputs:
      - '@globs(sources)'
      - '@group(projectConfigs)'
    outputs:
      - 'dist/src'
      - 'dist/test'
      - 'dist/tsconfig.tsbuildinfo'

When executing chat:build only chat:buildComponentTypes and chat:build are being attempted and on a clean workspace they fail because the necessary files for base (@backstage-components/base) and attendee-container (`@backstage-components/attendee-container) projects have not been built.

Expected behavior

Peer dependencies should have their tasks executed when dependencies declared using the "carrot" (^:build in this example).

Environment

  System:
    OS: macOS 14.1.1
    CPU: (8) arm64 Apple M1
    Memory: 279.11 MB / 16.00 GB
    Shell: 5.2.15 - /opt/homebrew/bin/bash
  Binaries:
    Node: 18.17.0 - ~/.volta/tools/image/node/18.17.0/bin/node
    Yarn: 3.6.3 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 9.8.1 - ~/.volta/tools/image/npm/9.8.1/bin/npm
    Watchman: 2023.10.23.00 - /opt/homebrew/bin/watchman
  Managers:
    Cargo: 1.71.1 - ~/.cargo/bin/cargo
    Gradle: 8.4 - /opt/homebrew/bin/gradle
    Homebrew: 4.1.17 - /opt/homebrew/bin/brew
    Maven: 3.9.5 - /opt/homebrew/bin/mvn
    pip3: 23.2.1 - /opt/homebrew/bin/pip3
    RubyGems: 3.0.3.1 - /usr/bin/gem
  Utilities:
    CMake: 3.27.7 - /opt/homebrew/bin/cmake
    Make: 3.81 - /usr/bin/make
    GCC: 15.0.0 - /usr/bin/gcc
    Git: 2.42.0 - /opt/homebrew/bin/git
    Clang: 15.0.0 - /usr/bin/clang
    Curl: 8.1.2 - /usr/bin/curl
  Servers:
    Apache: 2.4.56 - /usr/sbin/apachectl
  Virtualization:
    Docker: 24.0.6 - /usr/local/bin/docker
  IDEs:
    IntelliJ: 2023.2.4
    VSCode: 1.84.2 - /usr/local/bin/code
    Vim: 9.0 - /opt/homebrew/bin/vim
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Bash: 5.2.15 - /opt/homebrew/bin/bash
    Go: 1.21.3 - /opt/homebrew/bin/go
    Java: 11.0.17 - /usr/bin/javac
    Perl: 5.30.3 - /usr/bin/perl
    Python3: 3.11.6 - /opt/homebrew/bin/python3
    Ruby: 2.6.10 - /usr/bin/ruby
    Rust: 1.71.1 - /Users/bryanjswift/.cargo/bin/rustc
  Databases:
    SQLite: 3.39.5 - /usr/bin/sqlite3
  Browsers:
    Brave Browser: 118.1.59.124
    Chrome: 118.0.5993.117
    Safari: 17.1
  Monorepos:
    Yarn Workspaces: 3.6.3

Additional context

This was a breaking change somewhere between v1.11.1 to v1.14.0 but persists in v1.16.1 to which I'm currently attempting to update (from v1.11.1).

bryanjswift commented 1 year ago

If I query the chat project I get this from moon query projects --json project=chat. This is interesting to me because the tasks section (which I'm assuming is what moon sees after expansion of tasks) indicates only the dependency of chat:buildComponentTypes for the build task where I would expect to see attendee-container:build, base:build and chat:buildComponentTypes going from the dependencies and the task definition.

{
  "projects": [
    {
      "alias": "@backstage-components/chat",
      "config": {
        "schema": "https://moonrepo.dev/schemas/project.json",
        "dependsOn": [
          {
            "id": "attendee-container",
            "scope": "development",
            "source": "implicit",
            "via": "@backstage-components/attendee-container"
          },
          {
            "id": "base",
            "scope": "development",
            "source": "implicit",
            "via": "@backstage-components/base"
          },
          {
            "id": "attendee-container",
            "scope": "peer",
            "source": "implicit",
            "via": "@backstage-components/attendee-container"
          },
          {
            "id": "base",
            "scope": "peer",
            "source": "implicit",
            "via": "@backstage-components/base"
          }
        ],
        "env": {},
        "fileGroups": {},
        "language": "unknown",
        "owners": {
          "customGroups": {},
          "defaultOwner": null,
          "optional": false,
          "paths": [],
          "requiredApprovals": 1
        },
        "platform": null,
        "project": null,
        "tags": [
          "component"
        ],
        "tasks": {},
        "toolchain": {
          "node": null,
          "rust": null,
          "typescript": null
        },
        "type": "unknown",
        "workspace": {
          "inheritedTasks": {
            "exclude": [
              "build"
            ],
            "include": null,
            "rename": {
              "buildComponent": "build"
            }
          }
        }
      },
      "dependencies": {
        "base": {
          "id": "base",
          "scope": "peer",
          "source": "implicit",
          "via": "@backstage-components/base"
        },
        "attendee-container": {
          "id": "attendee-container",
          "scope": "peer",
          "source": "implicit",
          "via": "@backstage-components/attendee-container"
        }
      },
      "fileGroups": {
        "configs": {
          "files": [],
          "globs": [
            "component-packages/chat/*.{js,json}"
          ],
          "id": "configs"
        },
        "sources": {
          "files": [],
          "globs": [
            "component-packages/chat/src/**/*",
            "component-packages/chat/types/**/*"
          ],
          "id": "sources"
        },
        "tests": {
          "files": [],
          "globs": [
            "component-packages/chat/test/**/*.test.*",
            "component-packages/chat/src/__tests__/**/*"
          ],
          "id": "tests"
        },
        "projectConfigs": {
          "files": [
            "component-packages/chat/package.json",
            "component-packages/chat/tsconfig.json"
          ],
          "globs": [],
          "id": "projectConfigs"
        },
        "prettier": {
          "files": [
            ".prettierignore",
            ".prettierrc"
          ],
          "globs": [],
          "id": "prettier"
        }
      },
      "id": "chat",
      "inherited": {
        "order": [
          "*",
          "node",
          "typescript",
          "node-unknown",
          "typescript-unknown",
          "tag-component"
        ],
        "layers": {
          ".moon/tasks.yml": {
            "$schema": "https://moonrepo.dev/schemas/tasks.json",
            "fileGroups": {
              "configs": [
                "*.{js,json}"
              ],
              "tests": [
                "test/**/*.test.*",
                "src/__tests__/**/*"
              ],
              "sources": [
                "src/**/*",
                "types/**/*"
              ],
              "projectConfigs": [
                "package.json",
                "tsconfig.json"
              ],
              "prettier": [
                "/.prettierignore",
                "/.prettierrc"
              ]
            }
          },
          ".moon/tasks/tag-component.yml": {
            "$schema": "https://moonrepo.dev/schemas/tasks.json",
            "tasks": {
              "buildComponent": {
                "command": "node ../../scripts/build-component.js .",
                "deps": [
                  "^:build",
                  "~:buildComponentTypes"
                ],
                "inputs": [
                  "@globs(sources)",
                  "@group(projectConfigs)"
                ],
                "outputs": [
                  "dist/index.js",
                  "dist/index.js.map",
                  "dist/index.mjs",
                  "dist/index.mjs.map"
                ],
                "platform": "system"
              },
              "buildComponentTypes": {
                "command": "tsc --build",
                "deps": [
                  "^:build"
                ],
                "inputs": [
                  "@globs(sources)",
                  "@group(projectConfigs)"
                ],
                "outputs": [
                  "dist/src",
                  "dist/test",
                  "dist/tsconfig.tsbuildinfo"
                ],
                "platform": "node"
              },
              "watchComponent": {
                "command": "node ../../scripts/build-component.js . --watch",
                "deps": [
                  "^:build"
                ],
                "local": true,
                "platform": "system"
              }
            }
          },
          ".moon/tasks/typescript.yml": {
            "$schema": "https://moonrepo.dev/schemas/tasks.json",
            "tasks": {
              "build": {
                "command": "tsc --build",
                "deps": [
                  "^:build"
                ],
                "inputs": [
                  "@globs(sources)",
                  "@globs(tests)",
                  "@group(projectConfigs)"
                ],
                "outputs": [
                  "dist"
                ],
                "platform": "node"
              },
              "format": {
                "command": "prettier --ignore-path ../../.prettierignore --config ../../.prettierrc --write .",
                "inputs": [
                  "@globs(configs)",
                  "@files(prettier)",
                  "@globs(sources)",
                  "@globs(tests)"
                ],
                "options": {
                  "runInCI": false
                },
                "platform": "node"
              },
              "gen-tsconfig-ref": {
                "command": "ts-node scripts/development/update-tsconfig-refs.ts",
                "args": [
                  "$projectSource"
                ],
                "inputs": [
                  "package.json",
                  "/scripts/development/update-tsconfig-refs.ts"
                ],
                "options": {
                  "runInCI": false,
                  "runFromWorkspaceRoot": true
                },
                "platform": "node"
              },
              "test": {
                "command": "jest --passWithNoTests --reporters=default --reporters=jest-junit",
                "deps": [
                  "^:build"
                ],
                "inputs": [
                  "@globs(sources)",
                  "@globs(tests)",
                  "@group(projectConfigs)",
                  "jest.config.js"
                ],
                "outputs": [
                  "junit.xml"
                ],
                "options": {
                  "outputStyle": "buffer-only-failure"
                },
                "platform": "node"
              },
              "watch": {
                "command": "tsc --build --watch",
                "deps": [
                  "^:build"
                ],
                "local": true,
                "platform": "node"
              },
              "watchTest": {
                "command": "jest --passWithNoTests --reporters=default --watch",
                "deps": [
                  "^:build"
                ],
                "local": true,
                "platform": "node"
              }
            }
          }
        },
        "config": {
          "schema": "https://moonrepo.dev/schemas/tasks.json",
          "extends": null,
          "fileGroups": {
            "configs": [
              "*.{js,json}"
            ],
            "sources": [
              "src/**/*",
              "types/**/*"
            ],
            "tests": [
              "test/**/*.test.*",
              "src/__tests__/**/*"
            ],
            "projectConfigs": [
              "package.json",
              "tsconfig.json"
            ],
            "prettier": [
              "/.prettierignore",
              "/.prettierrc"
            ]
          },
          "implicitDeps": [],
          "implicitInputs": [],
          "tasks": {
            "build": {
              "extends": null,
              "command": "tsc --build",
              "args": null,
              "deps": [
                "^:build"
              ],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/typescript.yml"
              ],
              "inputs": [
                "@globs(sources)",
                "@globs(tests)",
                "@group(projectConfigs)"
              ],
              "local": null,
              "outputs": [
                "dist"
              ],
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": null,
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": null,
                "runFromWorkspaceRoot": null,
                "shell": null
              },
              "platform": "node",
              "type": null
            },
            "buildComponent": {
              "extends": null,
              "command": "node ../../scripts/build-component.js .",
              "args": null,
              "deps": [
                "^:build",
                "~:buildComponentTypes"
              ],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/tag-component.yml"
              ],
              "inputs": [
                "@globs(sources)",
                "@group(projectConfigs)"
              ],
              "local": null,
              "outputs": [
                "dist/index.js",
                "dist/index.js.map",
                "dist/index.mjs",
                "dist/index.mjs.map"
              ],
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": null,
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": null,
                "runFromWorkspaceRoot": null,
                "shell": null
              },
              "platform": "system",
              "type": null
            },
            "buildComponentTypes": {
              "extends": null,
              "command": "tsc --build",
              "args": null,
              "deps": [
                "^:build"
              ],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/tag-component.yml"
              ],
              "inputs": [
                "@globs(sources)",
                "@group(projectConfigs)"
              ],
              "local": null,
              "outputs": [
                "dist/src",
                "dist/test",
                "dist/tsconfig.tsbuildinfo"
              ],
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": null,
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": null,
                "runFromWorkspaceRoot": null,
                "shell": null
              },
              "platform": "node",
              "type": null
            },
            "format": {
              "extends": null,
              "command": "prettier --ignore-path ../../.prettierignore --config ../../.prettierrc --write .",
              "args": null,
              "deps": [],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/typescript.yml"
              ],
              "inputs": [
                "@globs(configs)",
                "@files(prettier)",
                "@globs(sources)",
                "@globs(tests)"
              ],
              "local": null,
              "outputs": null,
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": null,
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": false,
                "runFromWorkspaceRoot": null,
                "shell": null
              },
              "platform": "node",
              "type": null
            },
            "gen-tsconfig-ref": {
              "extends": null,
              "command": "ts-node scripts/development/update-tsconfig-refs.ts",
              "args": [
                "$projectSource"
              ],
              "deps": [],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/typescript.yml"
              ],
              "inputs": [
                "package.json",
                "/scripts/development/update-tsconfig-refs.ts"
              ],
              "local": null,
              "outputs": null,
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": null,
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": false,
                "runFromWorkspaceRoot": true,
                "shell": null
              },
              "platform": "node",
              "type": null
            },
            "test": {
              "extends": null,
              "command": "jest --passWithNoTests --reporters=default --reporters=jest-junit",
              "args": null,
              "deps": [
                "^:build"
              ],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/typescript.yml"
              ],
              "inputs": [
                "@globs(sources)",
                "@globs(tests)",
                "@group(projectConfigs)",
                "jest.config.js"
              ],
              "local": null,
              "outputs": [
                "junit.xml"
              ],
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": "buffer-only-failure",
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": null,
                "runFromWorkspaceRoot": null,
                "shell": null
              },
              "platform": "node",
              "type": null
            },
            "watch": {
              "extends": null,
              "command": "tsc --build --watch",
              "args": null,
              "deps": [
                "^:build"
              ],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/typescript.yml"
              ],
              "inputs": null,
              "local": true,
              "outputs": null,
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": null,
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": null,
                "runFromWorkspaceRoot": null,
                "shell": null
              },
              "platform": "node",
              "type": null
            },
            "watchComponent": {
              "extends": null,
              "command": "node ../../scripts/build-component.js . --watch",
              "args": null,
              "deps": [
                "^:build"
              ],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/tag-component.yml"
              ],
              "inputs": null,
              "local": true,
              "outputs": null,
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": null,
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": null,
                "runFromWorkspaceRoot": null,
                "shell": null
              },
              "platform": "system",
              "type": null
            },
            "watchTest": {
              "extends": null,
              "command": "jest --passWithNoTests --reporters=default --watch",
              "args": null,
              "deps": [
                "^:build"
              ],
              "env": {},
              "globalInputs": [
                "/.moon/tasks/typescript.yml"
              ],
              "inputs": null,
              "local": true,
              "outputs": null,
              "options": {
                "affectedFiles": null,
                "allowFailure": null,
                "cache": null,
                "envFile": null,
                "interactive": null,
                "mergeArgs": null,
                "mergeDeps": null,
                "mergeEnv": null,
                "mergeInputs": null,
                "mergeOutputs": null,
                "outputStyle": null,
                "persistent": null,
                "retryCount": null,
                "runDepsInParallel": null,
                "runInCI": null,
                "runFromWorkspaceRoot": null,
                "shell": null
              },
              "platform": "node",
              "type": null
            }
          }
        }
      },
      "language": "typescript",
      "platform": "node",
      "root": "/Users/bryanjswift/Documents/little-cinema/projects/backstage/component-packages/chat",
      "source": "component-packages/chat",
      "tasks": {
        "build": {
          "args": [
            "../../scripts/build-component.js",
            "."
          ],
          "command": "node",
          "deps": [
            "chat:buildComponentTypes"
          ],
          "env": {},
          "flags": {
            "emptyInputs": false,
            "expanded": true,
            "local": false
          },
          "id": "build",
          "inputs": [
            "@globs(sources)",
            "@group(projectConfigs)",
            "/.moon/*.yml",
            "/.moon/tasks/tag-component.yml"
          ],
          "inputFiles": [
            ".moon/tasks/tag-component.yml",
            "component-packages/chat/tsconfig.json",
            "component-packages/chat/package.json"
          ],
          "inputGlobs": [
            "component-packages/chat/src/**/*",
            "component-packages/chat/types/**/*",
            ".moon/*.yml"
          ],
          "inputVars": [],
          "options": {
            "affectedFiles": null,
            "allowFailure": false,
            "cache": true,
            "envFile": null,
            "interactive": false,
            "mergeArgs": "append",
            "mergeDeps": "append",
            "mergeEnv": "append",
            "mergeInputs": "append",
            "mergeOutputs": "append",
            "outputStyle": null,
            "persistent": false,
            "retryCount": 0,
            "runDepsInParallel": true,
            "runInCI": true,
            "runFromWorkspaceRoot": false,
            "shell": true
          },
          "outputs": [
            "dist/index.js",
            "dist/index.js.map",
            "dist/index.mjs",
            "dist/index.mjs.map"
          ],
          "outputFiles": [
            "component-packages/chat/dist/index.js.map",
            "component-packages/chat/dist/index.mjs",
            "component-packages/chat/dist/index.js",
            "component-packages/chat/dist/index.mjs.map"
          ],
          "outputGlobs": [],
          "platform": "system",
          "target": "chat:build",
          "type": "build"
        },
        "buildComponentTypes": {
          "args": [
            "--build"
          ],
          "command": "tsc",
          "deps": [],
          "env": {},
          "flags": {
            "emptyInputs": false,
            "expanded": true,
            "local": false
          },
          "id": "buildComponentTypes",
          "inputs": [
            "@globs(sources)",
            "@group(projectConfigs)",
            "/.moon/*.yml",
            "/.moon/tasks/tag-component.yml"
          ],
          "inputFiles": [
            ".moon/tasks/tag-component.yml",
            "component-packages/chat/tsconfig.json",
            "component-packages/chat/package.json"
          ],
          "inputGlobs": [
            "component-packages/chat/src/**/*",
            "component-packages/chat/types/**/*",
            ".moon/*.yml"
          ],
          "inputVars": [],
          "options": {
            "affectedFiles": null,
            "allowFailure": false,
            "cache": true,
            "envFile": null,
            "interactive": false,
            "mergeArgs": "append",
            "mergeDeps": "append",
            "mergeEnv": "append",
            "mergeInputs": "append",
            "mergeOutputs": "append",
            "outputStyle": null,
            "persistent": false,
            "retryCount": 0,
            "runDepsInParallel": true,
            "runInCI": true,
            "runFromWorkspaceRoot": false,
            "shell": true
          },
          "outputs": [
            "dist/src",
            "dist/test",
            "dist/tsconfig.tsbuildinfo"
          ],
          "outputFiles": [
            "component-packages/chat/dist/src",
            "component-packages/chat/dist/tsconfig.tsbuildinfo",
            "component-packages/chat/dist/test"
          ],
          "outputGlobs": [],
          "platform": "node",
          "target": "chat:buildComponentTypes",
          "type": "build"
        },
        "format": {
          "args": [
            "--ignore-path",
            "../../.prettierignore",
            "--config",
            "../../.prettierrc",
            "--write",
            "."
          ],
          "command": "prettier",
          "deps": [],
          "env": {},
          "flags": {
            "emptyInputs": false,
            "expanded": true,
            "local": false
          },
          "id": "format",
          "inputs": [
            "@globs(configs)",
            "@files(prettier)",
            "@globs(sources)",
            "@globs(tests)",
            "/.moon/*.yml",
            "/.moon/tasks/typescript.yml"
          ],
          "inputFiles": [
            ".moon/tasks/typescript.yml",
            ".prettierrc",
            ".prettierignore"
          ],
          "inputGlobs": [
            "component-packages/chat/*.{js,json}",
            "component-packages/chat/types/**/*",
            ".moon/*.yml",
            "component-packages/chat/src/**/*",
            "component-packages/chat/test/**/*.test.*",
            "component-packages/chat/src/__tests__/**/*"
          ],
          "inputVars": [],
          "options": {
            "affectedFiles": null,
            "allowFailure": false,
            "cache": true,
            "envFile": null,
            "interactive": false,
            "mergeArgs": "append",
            "mergeDeps": "append",
            "mergeEnv": "append",
            "mergeInputs": "append",
            "mergeOutputs": "append",
            "outputStyle": null,
            "persistent": false,
            "retryCount": 0,
            "runDepsInParallel": true,
            "runInCI": false,
            "runFromWorkspaceRoot": false,
            "shell": true
          },
          "outputs": [],
          "outputFiles": [],
          "outputGlobs": [],
          "platform": "node",
          "target": "chat:format",
          "type": "test"
        },
        "gen-tsconfig-ref": {
          "args": [
            "scripts/development/update-tsconfig-refs.ts",
            "component-packages/chat"
          ],
          "command": "ts-node",
          "deps": [],
          "env": {},
          "flags": {
            "emptyInputs": false,
            "expanded": true,
            "local": false
          },
          "id": "gen-tsconfig-ref",
          "inputs": [
            "package.json",
            "/scripts/development/update-tsconfig-refs.ts",
            "/.moon/*.yml",
            "/.moon/tasks/typescript.yml"
          ],
          "inputFiles": [
            ".moon/tasks/typescript.yml",
            "scripts/development/update-tsconfig-refs.ts",
            "component-packages/chat/package.json"
          ],
          "inputGlobs": [
            ".moon/*.yml"
          ],
          "inputVars": [],
          "options": {
            "affectedFiles": null,
            "allowFailure": false,
            "cache": true,
            "envFile": null,
            "interactive": false,
            "mergeArgs": "append",
            "mergeDeps": "append",
            "mergeEnv": "append",
            "mergeInputs": "append",
            "mergeOutputs": "append",
            "outputStyle": null,
            "persistent": false,
            "retryCount": 0,
            "runDepsInParallel": true,
            "runInCI": false,
            "runFromWorkspaceRoot": true,
            "shell": true
          },
          "outputs": [],
          "outputFiles": [],
          "outputGlobs": [],
          "platform": "node",
          "target": "chat:gen-tsconfig-ref",
          "type": "test"
        },
        "test": {
          "args": [
            "--passWithNoTests",
            "--reporters=default",
            "--reporters=jest-junit"
          ],
          "command": "jest",
          "deps": [],
          "env": {},
          "flags": {
            "emptyInputs": false,
            "expanded": true,
            "local": false
          },
          "id": "test",
          "inputs": [
            "@globs(sources)",
            "@globs(tests)",
            "@group(projectConfigs)",
            "jest.config.js",
            "/.moon/*.yml",
            "/.moon/tasks/typescript.yml"
          ],
          "inputFiles": [
            "component-packages/chat/package.json",
            ".moon/tasks/typescript.yml",
            "component-packages/chat/jest.config.js",
            "component-packages/chat/tsconfig.json"
          ],
          "inputGlobs": [
            ".moon/*.yml",
            "component-packages/chat/types/**/*",
            "component-packages/chat/src/**/*",
            "component-packages/chat/test/**/*.test.*",
            "component-packages/chat/src/__tests__/**/*"
          ],
          "inputVars": [],
          "options": {
            "affectedFiles": null,
            "allowFailure": false,
            "cache": true,
            "envFile": null,
            "interactive": false,
            "mergeArgs": "append",
            "mergeDeps": "append",
            "mergeEnv": "append",
            "mergeInputs": "append",
            "mergeOutputs": "append",
            "outputStyle": "buffer-only-failure",
            "persistent": false,
            "retryCount": 0,
            "runDepsInParallel": true,
            "runInCI": true,
            "runFromWorkspaceRoot": false,
            "shell": true
          },
          "outputs": [
            "junit.xml"
          ],
          "outputFiles": [
            "component-packages/chat/junit.xml"
          ],
          "outputGlobs": [],
          "platform": "node",
          "target": "chat:test",
          "type": "build"
        },
        "watch": {
          "args": [
            "--build",
            "--watch"
          ],
          "command": "tsc",
          "deps": [],
          "env": {},
          "flags": {
            "emptyInputs": false,
            "expanded": true,
            "local": true
          },
          "id": "watch",
          "inputs": [
            "**/*",
            "/.moon/*.yml",
            "/.moon/tasks/typescript.yml"
          ],
          "inputFiles": [
            ".moon/tasks/typescript.yml"
          ],
          "inputGlobs": [
            ".moon/*.yml",
            "component-packages/chat/**/*"
          ],
          "inputVars": [],
          "options": {
            "affectedFiles": null,
            "allowFailure": false,
            "cache": false,
            "envFile": null,
            "interactive": false,
            "mergeArgs": "append",
            "mergeDeps": "append",
            "mergeEnv": "append",
            "mergeInputs": "append",
            "mergeOutputs": "append",
            "outputStyle": "stream",
            "persistent": true,
            "retryCount": 0,
            "runDepsInParallel": true,
            "runInCI": false,
            "runFromWorkspaceRoot": false,
            "shell": true
          },
          "outputs": [],
          "outputFiles": [],
          "outputGlobs": [],
          "platform": "node",
          "target": "chat:watch",
          "type": "run"
        },
        "watchComponent": {
          "args": [
            "../../scripts/build-component.js",
            ".",
            "--watch"
          ],
          "command": "node",
          "deps": [],
          "env": {},
          "flags": {
            "emptyInputs": false,
            "expanded": true,
            "local": true
          },
          "id": "watchComponent",
          "inputs": [
            "**/*",
            "/.moon/*.yml",
            "/.moon/tasks/tag-component.yml"
          ],
          "inputFiles": [
            ".moon/tasks/tag-component.yml"
          ],
          "inputGlobs": [
            ".moon/*.yml",
            "component-packages/chat/**/*"
          ],
          "inputVars": [],
          "options": {
            "affectedFiles": null,
            "allowFailure": false,
            "cache": false,
            "envFile": null,
            "interactive": false,
            "mergeArgs": "append",
            "mergeDeps": "append",
            "mergeEnv": "append",
            "mergeInputs": "append",
            "mergeOutputs": "append",
            "outputStyle": "stream",
            "persistent": true,
            "retryCount": 0,
            "runDepsInParallel": true,
            "runInCI": false,
            "runFromWorkspaceRoot": false,
            "shell": true
          },
          "outputs": [],
          "outputFiles": [],
          "outputGlobs": [],
          "platform": "system",
          "target": "chat:watchComponent",
          "type": "run"
        },
        "watchTest": {
          "args": [
            "--passWithNoTests",
            "--reporters=default",
            "--watch"
          ],
          "command": "jest",
          "deps": [],
          "env": {},
          "flags": {
            "emptyInputs": false,
            "expanded": true,
            "local": true
          },
          "id": "watchTest",
          "inputs": [
            "**/*",
            "/.moon/*.yml",
            "/.moon/tasks/typescript.yml"
          ],
          "inputFiles": [
            ".moon/tasks/typescript.yml"
          ],
          "inputGlobs": [
            ".moon/*.yml",
            "component-packages/chat/**/*"
          ],
          "inputVars": [],
          "options": {
            "affectedFiles": null,
            "allowFailure": false,
            "cache": false,
            "envFile": null,
            "interactive": false,
            "mergeArgs": "append",
            "mergeDeps": "append",
            "mergeEnv": "append",
            "mergeInputs": "append",
            "mergeOutputs": "append",
            "outputStyle": "stream",
            "persistent": true,
            "retryCount": 0,
            "runDepsInParallel": true,
            "runInCI": false,
            "runFromWorkspaceRoot": false,
            "shell": true
          },
          "outputs": [],
          "outputFiles": [],
          "outputGlobs": [],
          "platform": "node",
          "target": "chat:watchTest",
          "type": "run"
        }
      },
      "type": "unknown"
    }
  ],
  "options": {
    "alias": null,
    "affected": false,
    "id": null,
    "json": true,
    "language": null,
    "query": "project=chat",
    "source": null,
    "tags": null,
    "tasks": null,
    "touched_files": [],
    "type_of": null
  }
}
bryanjswift commented 1 year ago

After moving the peer dependencies to dependencies I got the same behavior. Seems something about my configuration is preventing dependency resolution from functioning properly.

milesj commented 1 year ago

I'll take a look tomorrow, but in the meantime, do you see these logs: https://github.com/moonrepo/moon/blob/master/nextgen/project-expander/src/tasks_expander.rs#L67

And the eventual moon query for project=[a,b,c]: https://github.com/moonrepo/moon/blob/master/nextgen/project-expander/src/tasks_expander.rs#L142 Do you see this query in the logs, and is it querying the correct deps (base, attendee-container)?

bryanjswift commented 1 year ago

I'll take a look tomorrow, but in the meantime, do you see these logs: https://github.com/moonrepo/moon/blob/master/nextgen/project-expander/src/tasks_expander.rs#L67

And the eventual moon query for project=[a,b,c]: https://github.com/moonrepo/moon/blob/master/nextgen/project-expander/src/tasks_expander.rs#L142 Do you see this query in the logs, and is it querying the correct deps (base, attendee-container)?

moon run --log=trace chat:build 2>&1>& moon.log yields the attached log but notably it does not have the correct list of deps, I would expect this line to include ^:build in the deps part of the log.

[TRACE 11:17:26] moon_project_expander::tasks_expander:run  Expanding target scopes for deps  target="chat:build" deps=["~:buildComponentTypes"]

moon.log.zip

milesj commented 1 year ago

@bryanjswift Ok I recreated this here as best I can with the information given: https://github.com/moonrepo/moon/pull/1176 Does this look sort of correct?

What I think is happening, is that the original buildComponenttask has a dep for ^:build, but does the base/container packages rename the task to "build" or does it stay "buildComponent". If it's the latter, then that's why they don't show up as deps.

Those packages would also need this:

workspace:
  inheritedTasks:
    rename:
      buildComponent: build
bryanjswift commented 1 year ago

@bryanjswift Ok I recreated this here as best I can with the information given: #1176 Does this look sort of correct?

What I think is happening, is that the original buildComponenttask has a dep for ^:build, but does the base/container packages rename the task to "build" or does it stay "buildComponent". If it's the latter, then that's why they don't show up as deps.

Those packages would also need this:

workspace:
  inheritedTasks:
    rename:
      buildComponent: build

The dependent tasks also have this configuration:

workspace:
  inheritedTasks:
    # Exclude the inherited `build` task for this project
    exclude:
      - 'build'
    rename:
      buildComponent: 'build'

Everything with the component tag has this renaming configuration in its moon.yml file (which includes both @backstage-components/base and @backstage-components/attendee-container). A bit later I can see what happens if I don't do the task renaming in simply use the :buildComponent task in the deps.

Edit I added some comments to #1176 but it looks basically correct.

milesj commented 1 year ago

Ok cool, let me tinker some more.

bryanjswift commented 1 year ago

For what it is worth, I have been able to get my build working with the 1.16.4 release. I changed the buildComponent tag-component.yml to depend on ^:build and ^:buildComponent, it seems like the task exclusion works in dependency projects even if the task rename doesn’t.

milesj commented 1 year ago

Ok cool, I think I'll close this. Global tasks should use the names of the global tasks before they are renamed. Kind of hard to document this, but I'll give it a shot.