rsnext/packages/next-swc
Terence Bezman b20eb99a4d
Relay Support in Rust Compiler (#33240)
## Feature

Implements feature requested in https://github.com/vercel/next.js/issues/30805. 

A few people including myself have been looking to use Relay with Next.JS and want to use the new Rust Compiler. This is my stab at an implementation. 

### How it works?
Finds all  `graphql` tagged template experssions and replaces them with `require`s to the file generated by Relay.

### Where I need help
- I've only worked with Rust a handful of times so I would appreciate any feedback on my use of language features.
- Is there any performance overhead to many duplicate usages of `require`? I imagine there's a cache in place but I want to be sure.
- I've added some unit tests & integration tests but I might be missing some use cases. Feel free to comment some use cases I'm not thinking about.

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
  - I haven't added any docs since this is an experimental API.

## Documentation / Examples

You're expected to be running the Relay Compiler along side Next.JS when you're developing. This is pretty standard. I wouldn't expect people to have any problem with this.

### Usage
In your `next.config.js`
```js
module.exports = {
  experimental: {
    relay: {
      language: 'typescript', // or 'javascript`
      artifactDirectory: 'path/to/you/artifact/directory' // you can leave this undefined if you did not specify one in the `relay.json`
    }
  }
}
```


Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2022-01-26 08:23:57 +00:00
..
.cargo Update swc (#31963) 2021-11-30 15:12:37 +00:00
crates Relay Support in Rust Compiler (#33240) 2022-01-26 08:23:57 +00:00
native Extract next-swc Rust code into its own package (#31635) 2021-11-21 12:59:56 +01:00
.rustfmt.toml Extract next-swc Rust code into its own package (#31635) 2021-11-21 12:59:56 +01:00
Cargo.lock Relay Support in Rust Compiler (#33240) 2022-01-26 08:23:57 +00:00
Cargo.toml Extract next-swc Rust code into its own package (#31635) 2021-11-21 12:59:56 +01:00
package.json v12.0.9-canary.9 2022-01-25 10:53:28 -06:00
rust-toolchain Fix wasm loading (#31772) 2021-11-24 15:33:34 -08:00