google / google/wireit

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

Open
#1,315 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.4k
Forks
128
Avg merge
4d 10h
Merged PRs (30d)
4

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.

```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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.