Giter Club home page Giter Club logo

Comments (21)

kastermester avatar kastermester commented on July 24, 2024

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.

alloy avatar alloy commented on July 24, 2024

Oh smart! 👌

from relay-compiler-language-typescript.

kastermester avatar kastermester commented on July 24, 2024

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.

alloy avatar alloy commented on July 24, 2024

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.

kastermester avatar kastermester commented on July 24, 2024

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.

kastermester avatar kastermester commented on July 24, 2024

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.

alloy avatar alloy commented on July 24, 2024

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.

kastermester avatar kastermester commented on July 24, 2024

Of course :)

from relay-compiler-language-typescript.

alloy avatar alloy commented on July 24, 2024

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.

kastermester avatar kastermester commented on July 24, 2024

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.

alloy avatar alloy commented on July 24, 2024

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.

kastermester avatar kastermester commented on July 24, 2024

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.

alloy avatar alloy commented on July 24, 2024

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.

kastermester avatar kastermester commented on July 24, 2024

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.

alloy avatar alloy commented on July 24, 2024

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.

kastermester avatar kastermester commented on July 24, 2024

I already submitted a pull request in your relay repo :)

from relay-compiler-language-typescript.

kastermester avatar kastermester commented on July 24, 2024

alloy/relay#6

from relay-compiler-language-typescript.

alloy avatar alloy commented on July 24, 2024

Oohhhh. I wasn’t watching my own repo :D

from relay-compiler-language-typescript.

kastermester avatar kastermester commented on July 24, 2024

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.

kastermester avatar kastermester commented on July 24, 2024

I think we can close this now?

from relay-compiler-language-typescript.

alloy avatar alloy commented on July 24, 2024

Yup 👍

from relay-compiler-language-typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.