Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record "requiredFiles" in babel result, for cache key purposes #1401

Open
jpnelson opened this issue Mar 22, 2024 · 0 comments
Open

Record "requiredFiles" in babel result, for cache key purposes #1401

jpnelson opened this issue Mar 22, 2024 · 0 comments
Labels
feature: proposal 💬 New feature proposal that needs to be discussed needs: triage 🏷 Issue needs to be checked and prioritized

Comments

@jpnelson
Copy link
Contributor

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 as our build system, which has a per-file cache for transformations. This means that a file like this:

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)

const requiredFile = {
file: path.relative(id, filename),
    sha1: hashString(code)
};
this.requiredFiles.push(requiredFile);

Related Issues

@jpnelson jpnelson added the feature: proposal 💬 New feature proposal that needs to be discussed label Mar 22, 2024
@github-actions github-actions bot added the needs: triage 🏷 Issue needs to be checked and prioritized label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: proposal 💬 New feature proposal that needs to be discussed needs: triage 🏷 Issue needs to be checked and prioritized
Projects
None yet
Development

No branches or pull requests

1 participant