Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepo support #16

Open
FFdhorkin opened this issue Oct 18, 2023 · 1 comment
Open

Monorepo support #16

FFdhorkin opened this issue Oct 18, 2023 · 1 comment

Comments

@FFdhorkin
Copy link

FFdhorkin commented Oct 18, 2023

Currently, I have three package.json files - one at the workspace root, and two in sub-packages. I'd like to use package-changed from a script in the main package.json

For example (I am using pnpm):

./package.json (root folder):

{
    "scripts": {
        "package-changed": "package-changed run 'rm -f .eslintcache && pnpm install'"
    },
    "dependencies": {
        "subprojecta": "workspace:subprojecta",
        "subprojectb": "workspace:subprojectb"
    },
    "devDependencies": {
        "eslint": "^8.50.0",
        "husky": "^8.0.3",
        "package-changed": "^3.0.0"
   }
}

./subprojecta/package.json

{
    "devDependencies": {
       "typescript": "^5.2.2"
   }
}

./subprojectb/package.json

{
    "devDependencies": {
        "next": "^13.5.4"
   }
}

If the main package.json changes, or either of the subproject package.jsons change, I want the package-changed task to run.

I think this would be relatively simple, all things considered. Trickiest part would be detecting the workspaces in the first place (i.e. changes to src/find-package.ts). After that, I think it'd just require src/get-package-hash.ts to concatenate the various package.json files before hashing.

As an alternative to searching for multiple package.json files, there could also just be explicit cli-provided paths, e.g.
"package-changed": "package-changed --package ./package.json --package ./subprojecta/package.json --package ./subprojectb/package.json run 'rm -f .eslintcache && pnpm install'"

Right now, I think the only existing options are to either:

  • have separate package-changed scripts in each subproject and a script at the root that runs both
  • use the js api to manually run on multiple cwd
@FFdhorkin
Copy link
Author

As a side note, this might be a potential use case for the --lockfile flag discussed in #14

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

No branches or pull requests

1 participant