Giter Club home page Giter Club logo

Comments (15)

sgwilym avatar sgwilym commented on July 24, 2024 12

@spiegela The only issue I bumped into using CRA with relay-compiler-language-typescript was setting the location of the artifacts directory. With the change I made, all I've had to do is add the following to my package.json:

"babelMacros": {
    "relay": {
      "artifactDirectory": "./src/__generated__"
    }
  }

(you can also configure this in other places according to your taste – more detail on that in the PR).

from relay-compiler-language-typescript.

sibelius avatar sibelius commented on July 24, 2024 2

can we close this?

check a working example here https://github.com/sibelius/create-react-app-relay-modern

from relay-compiler-language-typescript.

sgwilym avatar sgwilym commented on July 24, 2024 1

@spiegela by the way, even though my changes have been merged, there’s not been a release including them yet!

from relay-compiler-language-typescript.

cberkom avatar cberkom commented on July 24, 2024

If I exclude the artifacts in my .tsconfig, it works, but not sure if that's intended.

"exclude": [
    "**/__generated__"
  ]

Sorry, new to typescript, let me know if I'm doing something stupid.

from relay-compiler-language-typescript.

kastermester avatar kastermester commented on July 24, 2024

I think #83 might solve the actual problem you're running into.

Besides that, here's a few notes:

Not using the single artifact directory should work just fine - but this will disable typechecking that the relay data you pass between components is actually correct (ie. you can now pass data to a component that has not had its data fetched). I understand the issue you run into here, but aside from working with the CRA team I'm not sure what we can do here.

Excluding the __generated__ directories from the TS compilation I would expect would stop the typechecker from working with those files. Can you import the files and get autocompletion in your components with this setup?

from relay-compiler-language-typescript.

alloy avatar alloy commented on July 24, 2024

I don’t have personal experience with CRA, but iirc there’s a project called babel-macros that would allow Babel configuration with CRA. (I don’t have fine to dive into that right now, but would welcome any patches necessary to make it work with that setup.)

from relay-compiler-language-typescript.

cberkom avatar cberkom commented on July 24, 2024

@kastermester You're correct that excluding the __generated__ directory broke autocompletion in my editor. I've reverted that change.

It looks like #83 hasn't been released yet, but I was able to get it working in the meantime by setting "noImplicitAny": false in .tsconfig. I recognize that this lowers the type-safety bar a bit.

@alloy Yes, we're using babel-plugin-relay/macro. It sounds like the only change needed is to point it at a different artifact directory?

from relay-compiler-language-typescript.

alloy avatar alloy commented on July 24, 2024

Unsure. What I meant more is that if we can support CRA through Babel-macros (I don’t even know what they do exactly) then that would be great.

from relay-compiler-language-typescript.

sgwilym avatar sgwilym commented on July 24, 2024

Bumped into this problem myself today. I've opened a PR that allows you to configure babel-plugin-relay options through the macro, but it's a change that has to be made on the plugin itself: facebook/relay#2646

from relay-compiler-language-typescript.

spiegela avatar spiegela commented on July 24, 2024

@sgwilym It looks like your change to configure babel-plugin-relay/macro got merged. Do you have an example of this with relay-compiler-language-typescript? I'm also running into issues with a CRA-2 app.

from relay-compiler-language-typescript.

alloy avatar alloy commented on July 24, 2024

You’re not actually using these settings in that example app, right? In any case, yeah feels like we can close this by now 👍

from relay-compiler-language-typescript.

spiegela avatar spiegela commented on July 24, 2024

Well, I checked the sample app, and it doesn't seem to relate to this issue. I know I came in late on this issue, but I'm experiencing the same result. However, this doesn't seem to be an issue with relay-compiler-language, rather I haven't gotten babel-plugin-relay/macro to recognize my artifactDirectory setting, yet-- I've tried various methods described in the links above.

I'll take this up with babel-plugin-relay, but out of curiosity is there a hard dependency for relay-compiler-language on a specific artifactDirectory for the generated ts files? My issue would also be solved if the default behavior of babel-plugin-relay/macro matched the default behavior of relay-compiler: placing the generated files in __generated__ directories in the same directory as the source file.

from relay-compiler-language-typescript.

alloy avatar alloy commented on July 24, 2024

@spiegela Thanks for the update! @sibelius Any chance you could update your example to use these macro settings?

As for the other question, please see this section of the type emission part of the Relay docs: https://facebook.github.io/relay/docs/en/type-emission.html#single-artifact-directory

from relay-compiler-language-typescript.

spiegela avatar spiegela commented on July 24, 2024

🤦‍♂️ Of course! I don't know why I didn't check to see if it was in a release. I'll take a look and see if I can test with babel-plugin-relay from master.

from relay-compiler-language-typescript.

RichardLindhout avatar RichardLindhout commented on July 24, 2024

Fix graphql errors with this
DefinitelyTyped/DefinitelyTyped#35707

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.