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

Bundling Relay fragments with packages published to NPM #4773

Open
willruggiano opened this issue Aug 19, 2024 · 4 comments
Open

Bundling Relay fragments with packages published to NPM #4773

willruggiano opened this issue Aug 19, 2024 · 4 comments

Comments

@willruggiano
Copy link

I've been searching all over for mentions of doing something like this but alas have not been able to find much of anything.

The idea is very simple. I have a package that contains some React components that internally use Relay. This package is published to NPM as its own library. I have another package that consumes the library as a dependency and uses the provided components as building blocks for a larger application. However, when I include a fragment defined in the library package in a query defined in the application package relay-compiler emits an error indicating that the included fragment is "undefined"... presumably it cannot locate this "third party" fragment.

Is something like this possible?

@sibelius
Copy link
Contributor

it is possible, just include this path in your relay config

@willruggiano
Copy link
Author

"include" it... how? Use a multi-project config? In which case is it a normal source or a generatedSource?

@striedinger
Copy link

We recently attempted this and the only way we got it to work was to run your code transpilation thru the relay plugin (babel or swc). Just make sure the consuming app uses the same compiler config and environment setup.

@willruggiano
Copy link
Author

Yeah, we ended up opting for a slightly different dx: "install" the component and provider code directly into the app via cli. Stole that idea for @shadcn/ui :)

I don't know what it was, maybe how I was bundling the shared library... but I could not get the relay-compiler to find the files. I tried several different relay configs; multi-project, generatedSources, etc etc to no avail lol

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

No branches or pull requests

3 participants