ITADN

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

#1315Openfilimon-danopoulos-stratsys 创建于 2025-05-07
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. ```json { "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: ```json { "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.
3 条评论