Metro has no supported way for a transform to state that its output depends on some other source file or graph-derived value.
For example:
// Card.tsx
export const Card = ({children}) => <View>{children}</View>;
// Screen.tsx
export const Screen = () => (
<Card>
<Text>Hello</Text>
</Card>
);
Say that we wanted to transform Screen.tsx, but only if Card.tsx wraps its children under a View. If Card later changes its wrapper component to something else, we need to undo this transformation.
Currently, this is not possible. If Card.tsx changes, Metro transforms Card.tsx, but not the unchanged Screen.tsx. Instead, it returns the old, transformed Screen.tsx from its cache because its cache key does not include Card.tsx.
I see two possible designs:
- A transform-dependency API that records additional file paths or input hashes.
- A graph-level analysis hook that runs after dependency discovery but before final transforms, and provides immutable per-file data to workers.
Related: #918, #1488, and #1605.
Metro has no supported way for a transform to state that its output depends on some other source file or graph-derived value.
For example:
Say that we wanted to transform
Screen.tsx, but only ifCard.tsxwraps its children under a View. If Card later changes its wrapper component to something else, we need to undo this transformation.Currently, this is not possible. If
Card.tsxchanges, Metro transformsCard.tsx, but not the unchangedScreen.tsx. Instead, it returns the old, transformedScreen.tsxfrom its cache because its cache key does not includeCard.tsx.I see two possible designs:
Related: #918, #1488, and #1605.