Skip to content

Conversation

@pavelglac
Copy link
Contributor

Issue: #5027

I am changing the order of execution when type section goes after staments section in order to ensure provided variable is already imported.

Description

When using provided variables and generating ES modules with relay-compiler (version 19.0.0 and verified also in 20.x), the generated code has the import statement for the provided variable placed after it is used. This results in incorrect import and execution order.

Current output:

({
  "__relay_internal__pv__file": id_provider
} as {
  readonly __relay_internal__pv__file: {
    readonly get: () => string;
  };
});

import id_provider from '../file';

New output:

import id_provider from '../file';

({
  "__relay_internal__pv__file": id_provider
} as {
  readonly __relay_internal__pv__file: {
    readonly get: () => string;
  };
});

@captbaritone
Copy link
Contributor

Excellent! Thanks for the fix. I'll import this and confirm that it does not trigger any issues internally.

@facebook-github-bot
Copy link
Contributor

@captbaritone has imported this pull request. If you are a Meta employee, you can view this in D77895571.

@pavelglac pavelglac force-pushed the pavelglac/fix-provided-varibles-import-order branch from c66652f to 7235225 Compare July 31, 2025 08:21
@pavelglac
Copy link
Contributor Author

@captbaritone I had to rebase this PR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants