Skip to content

Feature: support cross-file transform inputs with cache and watch invalidation #1902

Description

@mfkrause

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions