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

Generated ESM module import for provided variables has invalid Javascript syntax #4294

Closed
JingLi1998 opened this issue Apr 23, 2023 · 0 comments

Comments

@JingLi1998
Copy link
Contributor

When using provided variables, with ESM, the Relay compiler incorrectly assumes that the module path can also be reused for the default import name.

This is not valid Javascript as variables cannot use '.' or '-' characters.

To fix, simply replace '.' and '-' with underscores.

Before:

import include-can-edit-providers-three.relayprovider from './../include-can-edit-providers-three.relayprovider';
import include-can-edit-providers.relayprovider from './../include-can-edit-providers.relayprovider';
const providedVariablesDefinition: ProvidedVariablesType = {
  "__relay_internal__pv__includecaneditprovidersrelayprovider": include-can-edit-providers-three.relayprovider,
  "__relay_internal__pv__includecaneditprovidersthreerelayprovider": include-can-edit-providers.relayprovider
};

After:

import include_can_edit_providers_two_relayprovider from './../include-can-edit-providers-two.relayprovider';
import include_can_edit_providers_relayprovider from './../include-can-edit-providers.relayprovider';
const providedVariablesDefinition: ProvidedVariablesType = {
  "__relay_internal__pv__includecaneditprovidersrelayprovider": include_can_edit_providers_relayprovider,
  "__relay_internal__pv__includecaneditproviderstworelayprovider": include_can_edit_providers_two_relayprovider
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant