Comments (21)
I think we have an easier option here. What we have now mirrors the relay-compiler w/o haste enabled.
In RelayFileWriter there's a flag called outputDir
. If that is used then all the artifacts are output into that directory - thus enabling us to import all the reference types quite easily between the generated files. I have tested this and it works quite nicely, only thing is that the relay compiler binary does not allow passing it as a CLI argument, but that should be an easy fix.
from relay-compiler-language-typescript.
Oh smart! 👌
from relay-compiler-language-typescript.
Obviously that does mean that the runtime transform needs some loving - as it needs to require files from somewhere else. But I do think this is the most straightforward way we can go about this. How about I go to work on that runtime transform?
As far as I can tell we're not that far off having something here that actually works quite well. We just need the last few details to fall into place :) If there's some way I can figure out to make a runtime transformer that can utilize the code inside the babel transformer then that shouldn't be too large of a project I think.
from relay-compiler-language-typescript.
Do you mean to make the existing Babel plugin work with this single output directory? Because that would make it work for everybody in the short term. If you’re referring to a new TS plugin, then Flow users will still not be able to make use of this, which would be a shame (plus I imagine our patches will more easily get accepted if they serve everybody).
from relay-compiler-language-typescript.
True. Should i work on your PR to add the outputDir option and get the flow types working there when that is enabled do you think? That does actually not sound like a bad idea.
from relay-compiler-language-typescript.
What I originally meant was actually that instead of worrying about how to transform the code - I might be able to just locate the tags that needed transforming - call into the original babel code to transform it (which returns a babel AST) and then convert the babel AST to a TS AST and then emit that.
However I'm not sure what is easier here, it might be more feasible to simply port the babel code to use the TS AST - I figure the babel plugin is fairly stable as well, so it shouldn't cause too many problems moving forward.
from relay-compiler-language-typescript.
Yeah that sounds excellent. Keep in mind that some people (especially FB as they use Haste) will still want the artifacts next to the implementation files, so the flat output directory should be completely optional.
from relay-compiler-language-typescript.
Of course :)
from relay-compiler-language-typescript.
I suspect that porting the plugin completely will be easier to maintain than a hybrid solution. I haven’t actually looked at all the work the plugin does, though, I just assume it’s kinda trivial.
from relay-compiler-language-typescript.
There's a few things going on (idk if you've ever used Relay classic and had a look at that output - but that kind of transform is needed for classic/compat mode).
But I think porting the code should be sort of trivial - there's no external packages it depends on, except for babel, so we should be good.
from relay-compiler-language-typescript.
Ah yes, Classic. Yeah we’ve been Relay for a while now, but we’re fully migrated to Modern. Are you not planning to migrate any time soon?
from relay-compiler-language-typescript.
I don't think we'll have the luxury of doing a full sweep migration - we'll need to be running compat mode first.
On top of that we also have some old classic infrastructure that needs some adapting (we generated TS types for our fragments and containers previously as well). So for us getting everything to work is paramount before we can begin looking at migrating to a compat setup.
We also used a subscription library for relay classic - I still haven't yet had the time to look into how we're gonna migrate that. I'm sure it is doable however.
from relay-compiler-language-typescript.
Gotcha. I can attest that a full migration is not an easy feat, although in retrospect I think most of the issues I had were all in compat mode but YMMV.
from relay-compiler-language-typescript.
Yeah - I'm looking forward to the day where we have some proof of concept on relay in compat mode running. Gonna be interesting to see how easy it is to go from there to having it running in production.
from relay-compiler-language-typescript.
Just wanted to double-check if I misunderstood you earlier, are you going to work on adding the output dir and Babel transform fixes? If not then I may do so later tonight, as I’d like to wrap the first version up ASAP, seeing we’re very close.
from relay-compiler-language-typescript.
I already submitted a pull request in your relay repo :)
from relay-compiler-language-typescript.
alloy/relay#6
from relay-compiler-language-typescript.
Oohhhh. I wasn’t watching my own repo :D
from relay-compiler-language-typescript.
If you add that in then we'll only need minor modifications to the ts plugin to have that supporting the fragment imports as well (you can see the modification I made in the flow code).
from relay-compiler-language-typescript.
I think we can close this now?
from relay-compiler-language-typescript.
Yup 👍
from relay-compiler-language-typescript.
Related Issues (20)
- Generated refetch definition with variables can not pass the validation of backend, such as github.com/vektah/gqlparser/v2
- Generate GraphQL fragment files for VSCode GraphQL Extension fragment autocompletion HOT 2
- Cannot read property 'createKeywordTypeNode' of undefined HOT 8
- Support for [email protected] HOT 8
- Migrate travis CI release process to GitHub actions HOT 3
- Unknown directive 'appendNode' HOT 1
- module esnext HOT 2
- Why is it not releasing HOT 7
- `require` substitution is not working HOT 6
- doc: explain why configuration with a single artifact directory is suggested
- Update to TS 4.4 and update types to support exactOptionalPropertyTypes HOT 1
- @stream argument naming by schema spec is: `initialCount` not `initial_count` HOT 1
- Invalid AST Node error with graphql@16 HOT 2
- Typescript 4.5 type generation is broken HOT 6
- Relay Compiler generates Typescript Synthax error HOT 3
- Error: Cannot find module 'relay-compiler-language-typescript' on 15.0
- Fragment Typematching
- Input Types generated as readonly HOT 1
- deprecate this package HOT 1
- Issue with import of the __generated__
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from relay-compiler-language-typescript.