Curry printRequireModuleDependency with extension; add relative ./ path
Summary:
Suggested fix for
Pull Request resolved:
@@ -24,8 +24,10 @@ import type {FormatModule} from '../language/RelayLanguagePluginInterface';
import type CodegenDirectory from './CodegenDirectory';
import type {GeneratedNode} from 'relay-runtime';
-function printRequireModuleDependency(moduleName: string): string {
- return `require('${moduleName}')`;
+function createPrintRequireModuleDependency(
+ extension: string,
+): string => string {
+ return moduleName => `require('./${moduleName + extension}')`;
}
function getConcreteType(node: GeneratedNode): string {
@@ -56,7 +58,7 @@ async function writeRelayGeneratedFile(
extension: string,
printModuleDependency: (
moduleName: string,
- ) => string = printRequireModuleDependency,
+ ) => string = createPrintRequireModuleDependency(extension),
shouldRepersist: boolean,
): Promise<?GeneratedNode> {
let generatedNode = _generatedNode;
@@ -70,6 +72,7 @@ async function writeRelayGeneratedFile(
platform != null && platform.length > 0
? moduleName + '.' + platform
: moduleName;
+
const filename = platformName + '.' + extension;
const typeName = getConcreteType(generatedNode);
