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

[OSS v13 Compiler] Generate exact imports when using CommonJS and output #3675

Closed

Conversation

bigfootjon
Copy link
Member

The old JS compiler would generate exact foo$fragmentType imports when artifactDirectory is set since this allows the compiler to know where all the artifacts would be (all in the same directory).

The new compiler does not appear to support this currently. But this seemed easy enough to do, so I've taken a stab at it in this diff. I am not fluent in Rust (yet) so I am happy to take criticism on how to write this better!

Test plan:
cargo test passes

cargo run --bin relay -- ../../../myproject/relay.config.json produces the expected output.

Example file diff from the rc0 version of the compiler to this PR/Diff:

diff --git a/__generated__/BlogPostPageQuery.graphql.js b/__generated__/BlogPostPageQuery.graphql.js
index 96bd4fbf6..2911ddbd7 100644
--- a/__generated__/BlogPostPageQuery.graphql.js
+++ b/__generated__/BlogPostPageQuery.graphql.js
@@ -1,5 +1,5 @@
 /**
- * @generated SignedSource<<e8ed1071e6aabf5e4f69fd2c87674a6b>>
+ * @generated SignedSource<<f722c4d69fbe60872e2b896ecba50897>>
  * @flow
  * @lightSyntaxTransform
  * @nogrep
@@ -12,7 +12,7 @@
 
 /*::
 import type { ConcreteRequest, Query } from 'relay-runtime';
-type BlogPost_post$fragmentType = any;
+import type { BlogPost_post$fragmentType } from "./BlogPost_post.graphql";
 export type BlogPostPageQuery$variables = {|
   relativePath: string,
 |};

@facebook-github-bot
Copy link
Contributor

@bigfootjon has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@bigfootjon bigfootjon deleted the exact-types-in-unified-output branch December 6, 2021 20:11
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.

None yet

2 participants