Closed mmmulani closed 2 days ago
cc @tbezman based on #33240 and @alunyov in case he has any ideas for how best to interpret a Relay config to determine the generated artifact's path
What's the expected "fix"? Should the relay plugin accept multiple artifact paths?
yeah I think having the relay plugin allow for some multiple artifact paths would work. alternatively, some way to provide a function to generate the artifact path though i'm not sure if this is possible given the relay plugin is written in rust (and probably would be much slower)
the ideal solution would be parsing the relay config, and determining the expected artifact path from that.
hey, how does this work now? was looking through https://github.com/swc-project/plugins/commits/main/packages/relay for some example usage but couldn't find any
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Oops this is not fixed
https://github.com/swc-project/plugins/pull/318 adds multi-project support to swc_relay
.
I'll close this issue once I update next.js
whoa awesome, looks like a lot of work so thanks a ton!
is there any way to use this with older next versions? or is upgrading just the best way? (in case, maybe the swc plugin api changed?)
One plugin API is added and it's documented at https://github.com/swc-project/plugins/tree/aff55e5c6e1aceb18cfab49addb946f573fd13a4/packages/relay#example
You may configure @swc/relay
Wasm plugin directly via experimental.swcPlugins
like https://nextjs.org/docs/architecture/nextjs-compiler#swc-plugins-experimental
Link to the code that reproduces this issue
https://github.com/mmmulani/relay-multi/tree/main
To Reproduce
Note: The linked github repo has a workaround in place.
This issue is about using Relay's multi-project configuration to have graphQL queries in different "projects" where one project can reference another. The most common example of this is something like a "web" folder that uses graphQL fragments in a "shared" folder.
This is
shared/
that uses graphQL, e.g. TestComponent.tsx with:shared/TestComponent
insideweb-app/
Current vs. Expected behavior
Current behaviour: the import fails as the Relay SWC plugin expects the Relay generated graphQL file to live in
web-app/__generated__
rather thanshared/__generated__
Module not found: Can't resolve '/relay-multi/web-app/./__generated__/TestComponent_country.graphql.ts'
You would expect there to be some way to specify the multi project config inside the
next.config.js
file so that the plugin knows to look inshared/__generated__
rather thanweb-app/__generated__
.Workaround
You can workaround this by modifying module resolution in next.config.js with:
Provide environment information
Which area(s) are affected? (Select all that apply)
SWC
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
No response
PACK-2986