Skip to content

[request] Option to include additional fields in package.json in fingerprint. #1315

Description

I've had an issue recently where I changed the exports of a package in a monorepo. I expected this to invalidate the cache so that a build would fail but the build restored from cache instead masking the issue.

Work arounds

  1. Add the entire package.json as input. This invalidates the cache way to often. E.g. changing the linting script will invalidate the build script's cache.
  2. Manually extracting parts of package.json into separate files and depending on those.
{
  "scripts": {
    "build": "wireit"
    "extract-meta": "wireit"
  },
  "wireit": {
    "build": {
      "command": "tsc",
      "dependencies": [{
        "script": "extract-meta",
        "cascade": false
      }],
      "input": [
        "src/**",
        "meta/**"
      ],
       "output": [
         "dist/**",
         "typings/**"
       ]
    },
    "extract-meta": {
       "command": "node extract-meta.js",
       "input": [
         "package.json",
         "extract-meta.js"
       ],
       "output": [
         "meta/**"
       ]
     }
   }
}

This becomes verbose and error prone.

Suggestion

Include an option packageJsonFields (or similar) that allows us to include arbitrary package.json fields in the fingerprint. This reduces the configuration to:

{
  "scripts": {
    "build": "wireit"
  },
  "wireit": {
    "build": {
      "command": "tsc",
      "packageJsonFields": [
        "exports"
      ],
      "input": [
        "src/**",
        "meta/**"
      ],
       "output": [
         "dist/**",
         "typings/**"
       ]
    }
   }
}

Apart from solving the exports issue I faced it also allows other tools that use package.json for storing settings to be fingerprinted more efficiently with wireit.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions