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
- 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.
- 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.
I've had an issue recently where I changed the
exportsof 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
input. This invalidates the cache way to often. E.g. changing the linting script will invalidate the build script's cache.{ "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 arbitrarypackage.jsonfields 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
exportsissue I faced it also allows other tools that use package.json for storing settings to be fingerprinted more efficiently with wireit.