Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Error module not found
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
Related to https://github.com/facebook/relay/issues/3201, but thought I should post here because it may be specifically a Metro issue.
OS: Windows 10
Node: v12.18.3
react: 16.13.1
react-native: 0.63.3
react-relay: 10.0.1
Reproduction repository using the SWAPI server from here https://github.com/graphql/swapi-graphql.
https://github.com/benmurden/react-native-relay-windows-repro
This only happens when using the artifactDirectory option in Relay, and only when bundled with React Native i.e. Metro bundler; this all works in React Web.
Sorry, not sure how this one could be tested with yarn test. To reproduce:
relay.environment.js to match the port given by SWAPI serveryarn install && yarn relay && yarn android
Looks like a Windows directory issue, since the bundler seems to have prepended too many upward directory traversals (..\\..\\..\\).
What is the expected behavior?
App builds and runs on Windows 10 and Android.
Do you have a workaround available?
The isRelativeImport does not work on Windows it sees ..\generated not as relative while it is ;)
function isRelativeImport(filePath: string) {
return /^[.][.]?(?:[/]|$)/.test(filePath);
}
We fixed it by adding
function isRelativeImport(filePath: string) {
if (filePath.startsWith('..\\') {
return true;
}
return /^[.][.]?(?:[/]|$)/.test(filePath);
}
@benmurden thanks for pointing into the right direction!
@RichardLindhout Thanks! I was inspired to create a PR that will not only resolve the above issue, but also fix current directory relative imports (.\\).
Most helpful comment
@RichardLindhout Thanks! I was inspired to create a PR that will not only resolve the above issue, but also fix current directory relative imports (
.\\).648