Record "requiredFiles" in babel result, for cache key purposes
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 413
- PR merge metrics
- No merged PRs in 30d
Description
## Describe the feature
Add "requiredFiles" to the babel result, that lists the file paths + hashes of each file that gets used in static evaluation.
## Motivation
Something we've done and found useful is recording the files that get required during static evaluation in the babel result (the paths, and the sha1 of each file). This is useful as it lets us cache the result of transforms, and know when to bust this cache too. We're using [metro](https://metrobundler.dev/) as our build system, which has a per-file cache for transformations. This means that a file like this:
```ts
import { constant } from './file';
css`
background: ${constant}
`;
```
that we need to bust the cache if the `constant` changes.
## Possible implementations
We figured this out on the version of linaria we're on, in `module.ts` (at least in the version we're on, I'm sure this is possible in the latest linaria, too)
```ts
const requiredFile = {
file: path.relative(id, filename),
sha1: hashString(code)
};
this.requiredFiles.push(requiredFile);
```
## Related Issues
Contributor guide
Assessment
This issue has not been assessed yet.