diff --git a/docs/advanced-features/compiler.md b/docs/advanced-features/compiler.md index ac07f30fe24c1..0ed7b6b9a532b 100644 --- a/docs/advanced-features/compiler.md +++ b/docs/advanced-features/compiler.md @@ -94,6 +94,19 @@ const customJestConfig = { module.exports = createJestConfig(customJestConfig) ``` +### Relay + +To enable [Relay](https://relay.dev/) support: + +```js +// next.config.js +module.exports = { + experimental: { + relay: true, + }, +} +``` + ### Remove React Properties Allows to remove JSX properties. This is often used for testing. Similar to `babel-plugin-react-remove-properties`. diff --git a/package.json b/package.json index e38083a606fee..17f4d58ac5ec6 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "@types/http-proxy": "1.17.3", "@types/jest": "24.0.13", "@types/node": "13.11.0", + "@types/relay-runtime": "13.0.0", "@types/selenium-webdriver": "4.0.15", "@types/sharp": "0.29.3", "@types/string-hash": "1.1.1", @@ -145,6 +146,8 @@ "react-dom": "17.0.2", "react-dom-18": "npm:react-dom@18.0.0-rc.0", "react-ssr-prepass": "1.0.8", + "relay-compiler": "13.0.1", + "relay-runtime": "13.0.1", "release": "6.3.0", "request-promise-core": "1.1.2", "resolve-from": "5.0.0", diff --git a/packages/next-swc/Cargo.lock b/packages/next-swc/Cargo.lock index 71bbaccd17e56..e6fd178ca52eb 100644 --- a/packages/next-swc/Cargo.lock +++ b/packages/next-swc/Cargo.lock @@ -33,7 +33,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.4", "once_cell", "serde", "version_check", @@ -59,9 +59,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.51" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" +checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" [[package]] name = "arrayvec" @@ -89,6 +89,17 @@ dependencies = [ "syn", ] +[[package]] +name = "async-trait" +version = "0.1.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -145,19 +156,55 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "beef" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "474a626a67200bd107d44179bb3d4fc61891172d11696609264589be6a0e6a43" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array", + "generic-array 0.14.5", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", ] [[package]] @@ -192,9 +239,15 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" + +[[package]] +name = "byte-tools" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" @@ -202,11 +255,33 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "iovec", +] + +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +dependencies = [ + "serde", +] + [[package]] name = "cc" version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +dependencies = [ + "jobserver", +] [[package]] name = "cfg-if" @@ -236,14 +311,52 @@ dependencies = [ ] [[package]] -name = "cloudabi" -version = "0.1.0" +name = "clap" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ + "ansi_term", + "atty", "bitflags", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", ] +[[package]] +name = "colored" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "common" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "colored", + "indexmap", + "intern", + "log", + "lsp-types", + "md-5", + "rayon", + "serde", +] + +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -254,6 +367,22 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "cpufeatures" version = "0.2.1" @@ -274,9 +403,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -295,9 +424,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -308,9 +437,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" dependencies = [ "cfg-if 1.0.0", "lazy_static", @@ -352,7 +481,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.9.3", "syn", ] @@ -375,6 +504,8 @@ checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" dependencies = [ "cfg-if 1.0.0", "num_cpus", + "rayon", + "serde", ] [[package]] @@ -386,6 +517,19 @@ dependencies = [ "unreachable", ] +[[package]] +name = "dependency-analyzer" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "fnv", + "graphql-ir", + "graphql-syntax", + "intern", + "relay-transforms", + "schema", +] + [[package]] name = "diff" version = "0.1.12" @@ -398,13 +542,22 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array", + "generic-array 0.14.5", ] [[package]] @@ -431,18 +584,88 @@ dependencies = [ "syn", ] +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errors" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", +] + +[[package]] +name = "extract-graphql" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "graphql-syntax", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fastrand" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2" +dependencies = [ + "instant", +] + [[package]] name = "fixedbitset" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +[[package]] +name = "flatbuffers" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef4c5738bcd7fad10315029c50026f83c9da5e4a21f8ed66826f43e0e2bde5f6" +dependencies = [ + "bitflags", + "smallvec", + "thiserror", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.0.1" @@ -465,6 +688,102 @@ dependencies = [ "syn", ] +[[package]] +name = "futures" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" + +[[package]] +name = "futures" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" + +[[package]] +name = "futures-executor" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" + +[[package]] +name = "futures-macro" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" + +[[package]] +name = "futures-task" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" + +[[package]] +name = "futures-util" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" +dependencies = [ + "futures 0.1.31", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -476,9 +795,18 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.4" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" dependencies = [ "typenum", "version_check", @@ -497,9 +825,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ "cfg-if 1.0.0", "libc", @@ -518,6 +846,88 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "graphql-cli" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "colored", + "common", +] + +[[package]] +name = "graphql-ir" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "errors", + "fnv", + "graphql-syntax", + "intern", + "lazy_static", + "once_cell", + "schema", + "strsim 0.10.0", + "thiserror", +] + +[[package]] +name = "graphql-syntax" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "intern", + "logos", + "lsp-types", + "serde", + "thiserror", +] + +[[package]] +name = "graphql-text-printer" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "fnv", + "graphql-ir", + "graphql-syntax", + "intern", + "schema", +] + +[[package]] +name = "graphql-watchman" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "log", + "serde", + "serde_bser", + "watchman_client", +] + +[[package]] +name = "h2" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9de88456263e249e241fcd211d3954e2c9b0ef7ccfc235a444eb367cae3689" +dependencies = [ + "bytes 1.1.0", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.11.2" @@ -525,6 +935,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ "ahash", + "serde", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", ] [[package]] @@ -542,6 +962,86 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "http" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" +dependencies = [ + "bytes 1.1.0", + "fnv", + "itoa 1.0.1", +] + +[[package]] +name = "http-body" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +dependencies = [ + "bytes 1.1.0", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "hyper" +version = "0.14.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" +dependencies = [ + "bytes 1.1.0", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa 0.4.8", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes 1.1.0", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -567,23 +1067,48 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" [[package]] name = "indexmap" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" dependencies = [ "autocfg", "hashbrown", - "rayon", + "rayon", + "serde", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "intern" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "fnv", + "hashbrown", + "indexmap", + "once_cell", + "parking_lot", "serde", + "serde_bytes", + "serde_derive", + "smallvec", ] [[package]] -name = "instant" -version = "0.1.12" +name = "iovec" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" dependencies = [ - "cfg-if 1.0.0", + "libc", ] [[package]] @@ -601,9 +1126,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] @@ -614,6 +1139,31 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + +[[package]] +name = "jobserver" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] + +[[package]] +name = "js-config-loader" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "js-sys" version = "0.3.49" @@ -654,9 +1204,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.108" +version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" [[package]] name = "lock_api" @@ -674,6 +1224,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ "cfg-if 1.0.0", + "value-bag", +] + +[[package]] +name = "logos" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91c49573597a5d6c094f9031617bb1fed15c0db68c81e6546d313414ce107e4" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-derive" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "797b1f8a0571b331c1b47e7db245af3dc634838da7a92b3bef4e30376ae1c347" +dependencies = [ + "beef", + "fnv", + "proc-macro2", + "quote", + "regex-syntax", + "syn", + "utf8-ranges", ] [[package]] @@ -685,6 +1260,25 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "lsp-types" +version = "0.89.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852e0dedfd52cc32325598b2631e0eba31b7b708959676a9f837042f276b09a2" +dependencies = [ + "bitflags", + "serde", + "serde_json", + "serde_repr", + "url", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "matchers" version = "0.1.0" @@ -700,6 +1294,17 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +[[package]] +name = "md-5" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18af3dcaf2b0219366cdb4e2af65a6101457b415c3d1a5c71dd9c2b7c77b9c8" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "opaque-debug 0.2.3", +] + [[package]] name = "memchr" version = "2.4.1" @@ -708,9 +1313,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] @@ -751,6 +1356,28 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mio" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + [[package]] name = "napi" version = "1.8.0" @@ -765,9 +1392,9 @@ dependencies = [ [[package]] name = "napi-build" -version = "1.1.2" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d46af3cd13ef452354c8704da88bfc4bfa38724ddb38963a5113099749710788" +checksum = "ebd4419172727423cf30351406c54f6cc1b354a2cfb4f1dba3e6cd07f6d5522b" [[package]] name = "napi-derive" @@ -786,6 +1413,24 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67cf20e0081fea04e044aa4adf74cfea8ddc0324eec2894b1c700f4cafc72a56" +[[package]] +name = "native-tls" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -797,11 +1442,16 @@ name = "next-swc" version = "0.0.0" dependencies = [ "chrono", + "common", "easy-error", "either", "fxhash", + "intern", + "once_cell", "pathdiff", "regex", + "relay-compiler", + "relay-config", "serde", "serde_json", "styled_components", @@ -862,6 +1512,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + [[package]] name = "num-bigint" version = "0.2.6" @@ -895,9 +1554,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", @@ -914,9 +1573,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" + +[[package]] +name = "opaque-debug" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "opaque-debug" @@ -924,15 +1589,71 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl" +version = "0.10.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "ordered-float" -version = "2.8.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97c9d06878b3a851e8026ef94bf7fef9ba93062cd412601da4d9cf369b1cc62d" +checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" dependencies = [ "num-traits", ] +[[package]] +name = "ouroboros" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6d5c203fe8d786d9d7bec8203cbbff3eb2cf8410c0d70cfd05b3d5f5d545da" +dependencies = [ + "ouroboros_macro", + "stable_deref_trait", +] + +[[package]] +name = "ouroboros_macro" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "129943a960e6a08c7e70ca5a09f113c273fe7f10ae8420992c78293e3dffdf65" +dependencies = [ + "Inflector", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "output_vt100" version = "0.1.2" @@ -953,9 +1674,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", @@ -964,15 +1685,14 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.0" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", + "cfg-if 1.0.0", "instant", "libc", - "redox_syscall 0.1.57", + "redox_syscall", "smallvec", "winapi", ] @@ -995,6 +1715,19 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "persist-query" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "hyper", + "hyper-tls", + "serde", + "serde_json", + "thiserror", + "url", +] + [[package]] name = "petgraph" version = "0.5.1" @@ -1023,7 +1756,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ "phf_shared", - "rand 0.7.3", + "rand", ] [[package]] @@ -1051,9 +1784,21 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] name = "pmutil" @@ -1068,9 +1813,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "precomputed-hash" @@ -1122,18 +1867,24 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" -version = "1.0.10" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" dependencies = [ "proc-macro2", ] @@ -1152,24 +1903,12 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom 0.1.16", "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", + "rand_chacha", + "rand_core", + "rand_hc", "rand_pcg", ] -[[package]] -name = "rand" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", - "rand_hc 0.3.1", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -1177,17 +1916,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.3", + "rand_core", ] [[package]] @@ -1199,31 +1928,13 @@ dependencies = [ "getrandom 0.1.16", ] -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom 0.2.3", -] - [[package]] name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core 0.6.3", + "rand_core", ] [[package]] @@ -1232,7 +1943,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "rand_core 0.5.1", + "rand_core", ] [[package]] @@ -1260,12 +1971,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "redox_syscall" version = "0.2.10" @@ -1302,10 +2007,146 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] -name = "relative-path" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9629de8974fd69c97684736786b807edd3da456d3e3f95341dd9d4cbd8f5ad6" +name = "relative-path" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73d4caf086b102ab49d0525b721594a555ab55c6556086bbe52a430ad26c3bd7" + +[[package]] +name = "relay-codegen" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "fnv", + "graphql-ir", + "graphql-syntax", + "hex", + "indexmap", + "intern", + "lazy_static", + "md-5", + "relay-config", + "relay-transforms", + "schema", +] + +[[package]] +name = "relay-compiler" +version = "13.0.1" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "async-trait", + "bincode", + "common", + "common-path", + "dashmap", + "dependency-analyzer", + "env_logger", + "errors", + "extract-graphql", + "fnv", + "futures 0.3.19", + "glob", + "graphql-cli", + "graphql-ir", + "graphql-syntax", + "graphql-text-printer", + "graphql-watchman", + "hex", + "indexmap", + "intern", + "js-config-loader", + "lazy_static", + "log", + "md-5", + "persist-query", + "rayon", + "regex", + "relay-codegen", + "relay-config", + "relay-schema", + "relay-transforms", + "relay-typegen", + "schema", + "schema-diff", + "serde", + "serde_bser", + "serde_json", + "sha-1 0.8.2", + "signedsource", + "structopt", + "thiserror", + "tokio", + "walkdir", + "watchman_client", + "zstd", +] + +[[package]] +name = "relay-config" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "fnv", + "indexmap", + "intern", + "regex", + "serde", + "serde_json", +] + +[[package]] +name = "relay-schema" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "intern", + "schema", +] + +[[package]] +name = "relay-transforms" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "dashmap", + "errors", + "fnv", + "graphql-ir", + "graphql-syntax", + "graphql-text-printer", + "indexmap", + "intern", + "itertools", + "lazy_static", + "once_cell", + "parking_lot", + "regex", + "relay-config", + "schema", + "thiserror", +] + +[[package]] +name = "relay-typegen" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "fnv", + "graphql-ir", + "indexmap", + "intern", + "itertools", + "lazy_static", + "relay-config", + "relay-transforms", + "schema", +] [[package]] name = "remove_dir_all" @@ -1318,9 +2159,9 @@ dependencies = [ [[package]] name = "retain_mut" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "448296241d034b96c11173591deaa1302f2c17b56092106c1f92c1bc0183a8c9" +checksum = "11000e6ba5020e53e7cc26f73b91ae7d5496b4977851479edb66b694c0675c21" [[package]] name = "rustc-demangle" @@ -1345,9 +2186,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "same-file" @@ -1358,6 +2199,55 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi", +] + +[[package]] +name = "schema" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "dashmap", + "flatbuffers", + "fnv", + "graphql-syntax", + "intern", + "lazy_static", + "ouroboros", + "schema-flatbuffer", + "thiserror", +] + +[[package]] +name = "schema-diff" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "common", + "fnv", + "graphql-syntax", + "intern", + "lazy_static", + "relay-config", + "schema", +] + +[[package]] +name = "schema-flatbuffer" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "flatbuffers", +] + [[package]] name = "scoped-tls" version = "1.0.0" @@ -1370,6 +2260,29 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "security-framework" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.9.0" @@ -1415,6 +2328,28 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "serde_bser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b929ea725591083cbca8b8ea178ed6efc918eccd40b784e199ce88967104199" +dependencies = [ + "anyhow", + "byteorder", + "bytes 0.4.12", + "serde", + "thiserror", +] + +[[package]] +name = "serde_bytes" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.133" @@ -1428,11 +2363,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.72" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527" +checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142" dependencies = [ - "itoa", + "itoa 1.0.1", "ryu", "serde", ] @@ -1447,17 +2382,40 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + [[package]] name = "sha-1" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if 1.0.0", "cpufeatures", - "digest", - "opaque-debug", + "digest 0.9.0", + "opaque-debug 0.3.0", ] [[package]] @@ -1469,17 +2427,56 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "signedsource" +version = "0.0.0" +source = "git+https://github.com/facebook/relay?tag=v13.0.1#e10dba54b46fc01bdf3b6b811853c6f2b3e565b6" +dependencies = [ + "hex", + "lazy_static", + "md-5", + "regex", +] + [[package]] name = "siphasher" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" +[[package]] +name = "slab" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" + [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +dependencies = [ + "libc", + "winapi", +] [[package]] name = "sourcemap" @@ -1570,12 +2567,48 @@ dependencies = [ "syn", ] +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + [[package]] name = "strsim" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "structopt" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "styled_components" version = "0.13.0" @@ -1592,6 +2625,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "sval" +version = "1.0.0-alpha.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45f6ee7c7b87caf59549e9fe45d6a69c75c8019e79e212a835c5da0e92f0ba08" + [[package]] name = "swc" version = "0.117.2" @@ -2142,7 +3181,7 @@ dependencies = [ "once_cell", "regex", "serde", - "sha-1", + "sha-1 0.9.8", "string_enum", "swc_atoms", "swc_common", @@ -2165,7 +3204,7 @@ dependencies = [ "hex", "serde", "serde_json", - "sha-1", + "sha-1 0.9.8", "swc_common", "swc_ecma_ast", "swc_ecma_codegen", @@ -2367,14 +3406,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if 1.0.0", + "fastrand", "libc", - "rand 0.8.4", - "redox_syscall 0.2.10", + "redox_syscall", "remove_dir_all", "winapi", ] @@ -2408,9 +3447,9 @@ dependencies = [ [[package]] name = "testing_macros" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6976b6f5ffd18755bef29dce0e9e882382d53bc1ed9d414ccd5c0ee7346bc2" +checksum = "adfb26385ca4db3f8aa680824013819e3b9f8d9a1b64b4f83a411e09a61f11c3" dependencies = [ "anyhow", "glob", @@ -2422,6 +3461,15 @@ dependencies = [ "syn", ] +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.30" @@ -2476,6 +3524,69 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tokio" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" +dependencies = [ + "bytes 1.1.0", + "libc", + "memchr", + "mio", + "num_cpus", + "once_cell", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "tokio-macros", + "tracing", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +dependencies = [ + "bytes 1.1.0", + "futures-core", + "futures-io", + "futures-sink", + "log", + "pin-project-lite", + "slab", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + [[package]] name = "tracing" version = "0.1.29" @@ -2537,6 +3648,12 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + [[package]] name = "typed-arena" version = "2.0.1" @@ -2545,9 +3662,9 @@ checksum = "0685c84d5d54d1c26f7d3eb96cd41550adb97baed141a761cf335d3d33bcd0ae" [[package]] name = "typenum" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "unicode-bidi" @@ -2564,6 +3681,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" + [[package]] name = "unicode-width" version = "0.1.9" @@ -2595,13 +3718,43 @@ dependencies = [ "idna", "matches", "percent-encoding", + "serde", +] + +[[package]] +name = "utf8-ranges" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" + +[[package]] +name = "value-bag" +version = "1.0.0-alpha.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79923f7731dc61ebfba3633098bf3ac533bbd35ccd8c57e7088d9a5eebe0263f" +dependencies = [ + "ctor", + "sval", + "version_check", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" @@ -2620,6 +3773,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2720,6 +3883,24 @@ version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" +[[package]] +name = "watchman_client" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1afbab1186833c9b34f64132b80ed4b373ed4eab6f9efa1f55430835200f0a28" +dependencies = [ + "anyhow", + "bytes 1.1.0", + "futures 0.3.19", + "maplit", + "serde", + "serde_bser", + "thiserror", + "tokio", + "tokio-util", + "winapi", +] + [[package]] name = "web-sys" version = "0.3.49" @@ -2760,3 +3941,32 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zstd" +version = "0.8.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afab5e288c9e10bcd910b16ad82cb8028b74b09eccaa5ecd90621f99d3380735" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "4.0.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81f02c0811d5455aa82c6bc400cffd8c882f3a2813f5e2245e2b264443305ab2" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "1.5.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e6c094340240369025fc6b731b054ee2a834328fa584310ac96aa4baebdc465" +dependencies = [ + "cc", + "libc", +] diff --git a/packages/next-swc/crates/core/Cargo.toml b/packages/next-swc/crates/core/Cargo.toml index 0ccf231f91488..3c80ae0d3661f 100644 --- a/packages/next-swc/crates/core/Cargo.toml +++ b/packages/next-swc/crates/core/Cargo.toml @@ -8,6 +8,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] chrono = "0.4" +once_cell = "1.8.0" easy-error = "1.0.0" either = "1" fxhash = "0.2.1" @@ -26,6 +27,12 @@ swc_stylis = "0.43.0" tracing = {version = "0.1.28", features = ["release_max_level_off"]} regex = "1.5" +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +relay-compiler = { git = "https://github.com/facebook/relay", tag="v13.0.1" } +relay-compiler-intern = { package="intern", git = "https://github.com/facebook/relay", tag="v13.0.1" } +relay-compiler-common = { package = "common", git = "https://github.com/facebook/relay", tag="v13.0.1" } +relay-config = { git = "https://github.com/facebook/relay", tag="v13.0.1" } + [dev-dependencies] swc_ecma_transforms_testing = "0.59.0" testing = "0.18.0" diff --git a/packages/next-swc/crates/core/src/lib.rs b/packages/next-swc/crates/core/src/lib.rs index 1a36b3b2b5693..4d147f5a475b7 100644 --- a/packages/next-swc/crates/core/src/lib.rs +++ b/packages/next-swc/crates/core/src/lib.rs @@ -53,6 +53,8 @@ pub mod next_dynamic; pub mod next_ssg; pub mod page_config; pub mod react_remove_properties; +#[cfg(not(target_arch = "wasm32"))] +pub mod relay; pub mod remove_console; pub mod shake_exports; pub mod styled_jsx; @@ -91,6 +93,9 @@ pub struct TransformOptions { #[serde(default)] pub react_remove_properties: Option, + #[serde(default)] + pub relay: bool, + #[serde(default)] pub shake_exports: Option, } @@ -100,6 +105,17 @@ pub fn custom_before_pass( file: Arc, opts: &TransformOptions, ) -> impl Fold { + #[cfg(target_arch = "wasm32")] + let relay_plugin = noop(); + + #[cfg(not(target_arch = "wasm32"))] + let relay_plugin = { + match &opts.relay { + true => Either::Left(relay::relay(file.name.clone())), + false => Either::Right(noop()), + } + }; + chain!( disallow_re_export_all_in_page::disallow_re_export_all_in_page(opts.is_page_file), styled_jsx::styled_jsx(cm.clone()), @@ -130,6 +146,7 @@ pub fn custom_before_pass( page_config::page_config(opts.is_development, opts.is_page_file), !opts.disable_page_config ), + relay_plugin, match &opts.remove_console { Some(config) if config.truthy() => Either::Left(remove_console::remove_console(config.clone())), diff --git a/packages/next-swc/crates/core/src/relay.rs b/packages/next-swc/crates/core/src/relay.rs new file mode 100644 index 0000000000000..d3b655a0bdd11 --- /dev/null +++ b/packages/next-swc/crates/core/src/relay.rs @@ -0,0 +1,277 @@ +use once_cell::sync::Lazy; +use pathdiff::diff_paths; +use regex::Regex; +use relay_compiler::compiler_state::{SourceSet, SourceSetName}; +use relay_compiler::{create_path_for_artifact, FileCategorizer, FileGroup, ProjectConfig}; +use relay_compiler_common::SourceLocationKey; +use serde::Deserialize; +use std::borrow::Cow; +use std::path::{Path, PathBuf}; +use swc_atoms::JsWord; +use swc_common::errors::HANDLER; +use swc_common::FileName; +use swc_ecmascript::ast::*; +use swc_ecmascript::utils::{quote_ident, ExprFactory}; +use swc_ecmascript::visit::{Fold, FoldWith}; + +#[derive(Copy, Clone, Debug, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum RelayLanguageConfig { + Typescript, + Flow, +} + +struct Relay { + file_name: FileName, + relay_config_for_tests: Option, +} + +fn pull_first_operation_name_from_tpl(tpl: &TaggedTpl) -> Option { + tpl.tpl.quasis.iter().find_map(|quasis| { + static OPERATION_REGEX: Lazy = + Lazy::new(|| Regex::new(r"(fragment|mutation|query|subscription) (\w+)").unwrap()); + + let capture_group = OPERATION_REGEX.captures_iter(&quasis.raw.value).next(); + + match capture_group { + None => None, + Some(capture_group) => Some(capture_group[2].to_string()), + } + }) +} + +fn build_require_expr_from_path(path: &str) -> Expr { + Expr::Call(CallExpr { + span: Default::default(), + callee: quote_ident!("require").as_callee(), + args: vec![Lit::Str(Str { + span: Default::default(), + value: JsWord::from(path), + has_escape: false, + kind: Default::default(), + }) + .as_arg()], + type_args: None, + }) +} + +impl Fold for Relay { + fn fold_expr(&mut self, expr: Expr) -> Expr { + let expr = expr.fold_children_with(self); + + match &expr { + Expr::TaggedTpl(tpl) => { + if let Some(built_expr) = self.build_call_expr_from_tpl(tpl) { + built_expr + } else { + expr + } + } + _ => expr, + } + } +} + +#[derive(Debug)] +enum BuildRequirePathError<'a> { + FileNameNotReal, + MultipleSourceSetsFound { + source_set_names: Vec, + path: &'a PathBuf, + }, + ProjectNotFoundForSourceSet { + source_set_name: SourceSetName, + }, + FileNotASourceFile, + CouldNotCategorize { + err: Cow<'static, str>, + path: String, + }, +} + +// This is copied from https://github.com/facebook/relay/blob/main/compiler/crates/relay-compiler/src/build_project/generate_artifacts.rs#L251 +// until the Relay team exposes it for external use. +fn path_for_artifact( + root_dir: &Path, + source_path: &Path, + project_config: &ProjectConfig, + definition_name: &str, +) -> PathBuf { + let source_file_location_key = SourceLocationKey::Standalone { + path: source_path.to_str().unwrap().parse().unwrap(), + }; + let filename = if let Some(filename_for_artifact) = &project_config.filename_for_artifact { + filename_for_artifact(source_file_location_key, definition_name.parse().unwrap()) + } else { + match &project_config.typegen_config.language { + relay_config::TypegenLanguage::Flow => format!("{}.graphql.js", definition_name), + relay_config::TypegenLanguage::TypeScript => { + format!("{}.graphql.ts", definition_name) + } + } + }; + + let output_path = create_path_for_artifact(project_config, source_file_location_key, filename); + + if project_config.output.is_some() { + let absolute_output_path = root_dir.join(&output_path); + + let diffed_path = + diff_paths(&absolute_output_path, &source_path.parent().unwrap()).unwrap(); + + return diffed_path; + } + + output_path +} +impl Relay { + fn build_require_path( + &mut self, + operation_name: &str, + ) -> Result { + match &self.relay_config_for_tests { + Some(config) => match &self.file_name { + FileName::Real(real_file_path) => Ok(path_for_artifact( + &std::env::current_dir().unwrap(), + &real_file_path, + config, + operation_name, + )), + _ => Err(BuildRequirePathError::FileNameNotReal), + }, + _ => { + let config = + relay_compiler::config::Config::search(&std::env::current_dir().unwrap()) + .unwrap(); + + let categorizer = FileCategorizer::from_config(&config); + + match &self.file_name { + FileName::Real(real_file_name) => { + // Make sure we have a path which is relative to the config. + // Otherwise, categorize won't be able to recognize that + // the absolute source path is a child of a source set. + let diffed_path = diff_paths(real_file_name, &config.root_dir).unwrap(); + + let group = categorizer.categorize(diffed_path.as_path()); + + match group { + Ok(group) => match group { + FileGroup::Source { source_set } => match source_set { + SourceSet::SourceSetName(source_set_name) => { + let project_config: Option<&ProjectConfig> = + config.projects.get(&source_set_name); + + match project_config { + None => Err(BuildRequirePathError::ProjectNotFoundForSourceSet { source_set_name }), + Some(project_config) => { + Ok(path_for_artifact(&config.root_dir,real_file_name, &project_config, operation_name)) + } + } + } + SourceSet::SourceSetNames(source_set_names) => { + Err(BuildRequirePathError::MultipleSourceSetsFound { + source_set_names, + path: real_file_name, + }) + } + }, + _ => Err(BuildRequirePathError::FileNotASourceFile), + }, + Err(err) => Err(BuildRequirePathError::CouldNotCategorize { + err, + path: real_file_name.display().to_string(), + }), + } + } + _ => Err(BuildRequirePathError::FileNameNotReal), + } + } + } + } + + fn build_call_expr_from_tpl(&mut self, tpl: &TaggedTpl) -> Option { + if let Expr::Ident(ident) = &*tpl.tag { + if &*ident.sym != "graphql" { + return None; + } + } + + let operation_name = pull_first_operation_name_from_tpl(tpl); + + match operation_name { + None => None, + Some(operation_name) => match self.build_require_path(operation_name.as_str()) { + Ok(final_path) => Some(build_require_expr_from_path(final_path.to_str().unwrap())), + Err(err) => { + let base_error = "Could not transform GraphQL template to a Relay import."; + let error_message = match err { + BuildRequirePathError::FileNameNotReal => "Source file was not a real \ + file. This is likely a bug and \ + should be reported to Next.js" + .to_string(), + BuildRequirePathError::MultipleSourceSetsFound { + source_set_names, + path, + } => { + format!( + "Multiple source sets were found for file: {}. Found source sets: \ + [{}]. We could not determine the project config to use for the \ + source file. Please consider narrowing down your source sets.", + path.to_str().unwrap(), + source_set_names + .iter() + .map(|name| name.lookup()) + .collect::>() + .join(", ") + ) + } + BuildRequirePathError::ProjectNotFoundForSourceSet { source_set_name } => { + format!( + "Project could not be found for the source set: {}", + source_set_name + ) + } + BuildRequirePathError::FileNotASourceFile => { + "This file was not considered a source file by the Relay Compiler. \ + This is likely a bug and should be reported to Next.js" + .to_string() + } + BuildRequirePathError::CouldNotCategorize { path, err } => { + format!( + "Relay was unable to categorize the file at: {}. Ensure your \ + `src` path includes this file in `relay.config.js` The \ + underlying error is: {}. \n\nThis is likely a bug and should be \ + reported to Next.js", + path, err + ) + } + }; + + HANDLER.with(|handler| { + handler.span_err( + tpl.span, + format!("{} {}", base_error, error_message).as_str(), + ); + }); + + None + } + }, + } + } +} + +pub fn relay(file_name: FileName) -> impl Fold { + Relay { + file_name, + relay_config_for_tests: None, + } +} + +pub fn test_relay(file_name: FileName, relay_config_for_tests: ProjectConfig) -> impl Fold { + Relay { + file_name, + relay_config_for_tests: Some(relay_config_for_tests), + } +} diff --git a/packages/next-swc/crates/core/tests/fixture.rs b/packages/next-swc/crates/core/tests/fixture.rs index f575c26c3d8c4..dfb212f85f36d 100644 --- a/packages/next-swc/crates/core/tests/fixture.rs +++ b/packages/next-swc/crates/core/tests/fixture.rs @@ -1,3 +1,4 @@ +use next_swc::relay::test_relay; use next_swc::{ amp_attributes::amp_attributes, next_dynamic::next_dynamic, @@ -8,6 +9,8 @@ use next_swc::{ shake_exports::{shake_exports, Config as ShakeExportsConfig}, styled_jsx::styled_jsx, }; +use relay_compiler::ProjectConfig; +use relay_config::TypegenLanguage; use std::path::PathBuf; use swc_common::{chain, comments::SingleThreadedComments, FileName, Mark, Span, DUMMY_SP}; use swc_ecma_transforms_testing::{test, test_fixture}; @@ -149,6 +152,22 @@ fn page_config_fixture(input: PathBuf) { test_fixture(syntax(), &|_tr| page_config_test(), &input, &output); } +#[fixture("tests/fixture/relay/**/input.ts*")] +fn relay_no_artifact_dir_fixture(input: PathBuf) { + let output = input.parent().unwrap().join("output.js"); + test_fixture( + syntax(), + &|_tr| { + let mut config = ProjectConfig::default(); + config.typegen_config.language = TypegenLanguage::TypeScript; + + test_relay(FileName::Real(PathBuf::from("input.tsx")), config) + }, + &input, + &output, + ); +} + #[fixture("tests/fixture/remove-console/**/input.js")] fn remove_console_fixture(input: PathBuf) { let output = input.parent().unwrap().join("output.js"); diff --git a/packages/next-swc/crates/core/tests/fixture/relay/input.tsx b/packages/next-swc/crates/core/tests/fixture/relay/input.tsx new file mode 100644 index 0000000000000..8bc789841d4e1 --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/relay/input.tsx @@ -0,0 +1,42 @@ +const variableQuery = graphql` + query InputVariableQuery { + hello + } +` + +fetchQuery(graphql` + query InputUsedInFunctionCallQuery { + hello + } +`) + +function SomeQueryComponent() { + useLazyLoadQuery(graphql` + query InputInHookQuery { + hello + } + `) +} + +const variableMutation = graphql` + query InputVariableMutation { + someMutation + } +` + +commitMutation( + environment, + graphql` + query InputUsedInFunctionCallMutation { + someMutation + } + ` +) + +function SomeMutationComponent() { + useMutation(graphql` + query InputInHookMutation { + someMutation + } + `) +} \ No newline at end of file diff --git a/packages/next-swc/crates/core/tests/fixture/relay/output.js b/packages/next-swc/crates/core/tests/fixture/relay/output.js new file mode 100644 index 0000000000000..bf391cc8ff397 --- /dev/null +++ b/packages/next-swc/crates/core/tests/fixture/relay/output.js @@ -0,0 +1,13 @@ +const variableQuery = require('__generated__/InputVariableQuery.graphql.ts') +fetchQuery(require('__generated__/InputUsedInFunctionCallQuery.graphql.ts')) +function SomeQueryComponent() { + useLazyLoadQuery(require('__generated__/InputInHookQuery.graphql.ts')) +} +const variableMutation = require('__generated__/InputVariableMutation.graphql.ts') +commitMutation( + environment, + require('__generated__/InputUsedInFunctionCallMutation.graphql.ts') +) +function SomeMutationComponent() { + useMutation(require('__generated__/InputInHookMutation.graphql.ts')) +} diff --git a/packages/next-swc/crates/core/tests/full.rs b/packages/next-swc/crates/core/tests/full.rs index 834b14748d920..80c5bb0519513 100644 --- a/packages/next-swc/crates/core/tests/full.rs +++ b/packages/next-swc/crates/core/tests/full.rs @@ -59,6 +59,7 @@ fn test(input: &Path, minify: bool) { styled_components: Some(assert_json("{}")), remove_console: None, react_remove_properties: None, + relay: false, shake_exports: None, }; diff --git a/packages/next-swc/crates/wasm/Cargo.toml b/packages/next-swc/crates/wasm/Cargo.toml index ba836eb72c317..357fd01d81f12 100644 --- a/packages/next-swc/crates/wasm/Cargo.toml +++ b/packages/next-swc/crates/wasm/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] anyhow = "1.0.42" console_error_panic_hook = "0.1.6" once_cell = "1.3.1" -parking_lot_core = "=0.8.0" +parking_lot_core = "=0.8.5" path-clean = "0.1" serde = {version = "1", features = ["derive"]} serde_json = "1" diff --git a/packages/next/build/swc/options.js b/packages/next/build/swc/options.js index 103119885e47b..27bf7878acce6 100644 --- a/packages/next/build/swc/options.js +++ b/packages/next/build/swc/options.js @@ -75,6 +75,7 @@ function getBaseSWCOptions({ : null, removeConsole: nextConfig?.experimental?.removeConsole, reactRemoveProperties: nextConfig?.experimental?.reactRemoveProperties, + relay: nextConfig?.experimental?.relay, } } diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index ddd269cac3b80..d16f10b7631ff 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -1617,6 +1617,7 @@ export default async function getBaseWebpackConfig( removeConsole: config.experimental.removeConsole, reactRemoveProperties: config.experimental.reactRemoveProperties, styledComponents: config.experimental.styledComponents, + relay: config.experimental.relay, }) const cache: any = { diff --git a/packages/next/server/config-shared.ts b/packages/next/server/config-shared.ts index 7b22fd471a450..3a098d055e520 100644 --- a/packages/next/server/config-shared.ts +++ b/packages/next/server/config-shared.ts @@ -172,6 +172,7 @@ export type NextConfig = { [key: string]: any } & { urlImports?: NonNullable['buildHttp'] outputFileTracingRoot?: string outputStandalone?: boolean + relay?: boolean } } diff --git a/test/integration/relay-graphql-swc-multi-project/__generated__/pagesQuery.graphql.ts b/test/integration/relay-graphql-swc-multi-project/__generated__/pagesQuery.graphql.ts new file mode 100644 index 0000000000000..3963e412c6151 --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/__generated__/pagesQuery.graphql.ts @@ -0,0 +1,63 @@ +/** + * @generated SignedSource<<187ead9fb6e7b26d71c9161bda6ab902>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest, Query } from 'relay-runtime' +export type pagesQuery$variables = {} +export type pagesQueryVariables = pagesQuery$variables +export type pagesQuery$data = { + readonly greeting: string +} +export type pagesQueryResponse = pagesQuery$data +export type pagesQuery = { + variables: pagesQueryVariables + response: pagesQuery$data +} + +const node: ConcreteRequest = (function () { + var v0 = [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'greeting', + storageKey: null, + }, + ] + return { + fragment: { + argumentDefinitions: [], + kind: 'Fragment', + metadata: null, + name: 'pagesQuery', + selections: v0 /*: any*/, + type: 'Query', + abstractKey: null, + }, + kind: 'Request', + operation: { + argumentDefinitions: [], + kind: 'Operation', + name: 'pagesQuery', + selections: v0 /*: any*/, + }, + params: { + cacheID: '167b6de16340efeb876a7787c90e7cec', + id: null, + metadata: {}, + name: 'pagesQuery', + operationKind: 'query', + text: 'query pagesQuery {\n greeting\n}\n', + }, + } +})() + +;(node as any).hash = '4017856344f36f61252354e2eb442d98' + +export default node diff --git a/test/integration/relay-graphql-swc-multi-project/project-a/next.config.js b/test/integration/relay-graphql-swc-multi-project/project-a/next.config.js new file mode 100644 index 0000000000000..80e35cc588f55 --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/project-a/next.config.js @@ -0,0 +1,6 @@ +module.exports = { + experimental: { + relay: true, + externalDir: true, + }, +} diff --git a/test/integration/relay-graphql-swc-multi-project/project-a/pages/api/query.ts b/test/integration/relay-graphql-swc-multi-project/project-a/pages/api/query.ts new file mode 100644 index 0000000000000..5ad51e06bc09b --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/project-a/pages/api/query.ts @@ -0,0 +1,12 @@ +import { NextApiRequest, NextApiResponse } from 'next' + +export default function handler( + req: NextApiRequest, + res: NextApiResponse<{ data: { greeting: string } }> +) { + res.status(200).json({ + data: { + greeting: 'Hello, World!', + }, + }) +} diff --git a/test/integration/relay-graphql-swc-multi-project/project-a/pages/index.tsx b/test/integration/relay-graphql-swc-multi-project/project-a/pages/index.tsx new file mode 100644 index 0000000000000..c70a9e48aeb6b --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/project-a/pages/index.tsx @@ -0,0 +1,63 @@ +import { + Environment, + FetchFunction, + fetchQuery, + graphql, + Network, + RecordSource, + Store, +} from 'relay-runtime' +import { GetServerSideProps } from 'next' +import { pagesQuery } from '../../__generated__/pagesQuery.graphql' + +type Props = { greeting: string } + +export default function Index({ greeting }: Props) { + return

Project A:{greeting}

+} + +function createGraphQLFetcher(host: string | undefined): FetchFunction { + return async function fetchGraphQL(params, variables) { + const url = host ? `http://${host}/api/query` : `/api/query` + + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + query: params.text, + variables, + }), + }) + + return await response.json() + } +} + +export const getServerSideProps: GetServerSideProps = async ({ req }) => { + const environment = new Environment({ + store: new Store(new RecordSource({}), {}), + network: Network.create(createGraphQLFetcher(req.headers.host)), + }) + + const result = await fetchQuery( + environment, + graphql` + query pagesQuery { + greeting + } + `, + {} + ).toPromise() + + if (!result) { + throw new Error( + 'Mock GraphQL Server network request finished without a response!' + ) + } + + return { + props: { greeting: result.greeting }, + } +} diff --git a/test/integration/relay-graphql-swc-multi-project/project-a/tsconfig.json b/test/integration/relay-graphql-swc-multi-project/project-a/tsconfig.json new file mode 100644 index 0000000000000..a247e53e341ed --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/project-a/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "esModuleInterop": true, + "module": "esnext", + "jsx": "preserve", + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true + }, + "exclude": ["node_modules"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"] +} diff --git a/test/integration/relay-graphql-swc-multi-project/project-b/next.config.js b/test/integration/relay-graphql-swc-multi-project/project-b/next.config.js new file mode 100644 index 0000000000000..80e35cc588f55 --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/project-b/next.config.js @@ -0,0 +1,6 @@ +module.exports = { + experimental: { + relay: true, + externalDir: true, + }, +} diff --git a/test/integration/relay-graphql-swc-multi-project/project-b/pages/api/query.ts b/test/integration/relay-graphql-swc-multi-project/project-b/pages/api/query.ts new file mode 100644 index 0000000000000..5ad51e06bc09b --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/project-b/pages/api/query.ts @@ -0,0 +1,12 @@ +import { NextApiRequest, NextApiResponse } from 'next' + +export default function handler( + req: NextApiRequest, + res: NextApiResponse<{ data: { greeting: string } }> +) { + res.status(200).json({ + data: { + greeting: 'Hello, World!', + }, + }) +} diff --git a/test/integration/relay-graphql-swc-multi-project/project-b/pages/index.tsx b/test/integration/relay-graphql-swc-multi-project/project-b/pages/index.tsx new file mode 100644 index 0000000000000..547d72f775ef7 --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/project-b/pages/index.tsx @@ -0,0 +1,63 @@ +import { + Environment, + FetchFunction, + fetchQuery, + graphql, + Network, + RecordSource, + Store, +} from 'relay-runtime' +import { GetServerSideProps } from 'next' +import { pagesQuery } from '../../__generated__/pagesQuery.graphql' + +type Props = { greeting: string } + +export default function Index({ greeting }: Props) { + return

Project B:{greeting}

+} + +function createGraphQLFetcher(host: string | undefined): FetchFunction { + return async function fetchGraphQL(params, variables) { + const url = host ? `http://${host}/api/query` : `/api/query` + + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + query: params.text, + variables, + }), + }) + + return await response.json() + } +} + +export const getServerSideProps: GetServerSideProps = async ({ req }) => { + const environment = new Environment({ + store: new Store(new RecordSource({}), {}), + network: Network.create(createGraphQLFetcher(req.headers.host)), + }) + + const result = await fetchQuery( + environment, + graphql` + query pagesQuery { + greeting + } + `, + {} + ).toPromise() + + if (!result) { + throw new Error( + 'Mock GraphQL Server network request finished without a response!' + ) + } + + return { + props: { greeting: result.greeting }, + } +} diff --git a/test/integration/relay-graphql-swc-multi-project/project-b/tsconfig.json b/test/integration/relay-graphql-swc-multi-project/project-b/tsconfig.json new file mode 100644 index 0000000000000..a247e53e341ed --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/project-b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "esModuleInterop": true, + "module": "esnext", + "jsx": "preserve", + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true + }, + "exclude": ["node_modules"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"] +} diff --git a/test/integration/relay-graphql-swc-multi-project/relay.config.js b/test/integration/relay-graphql-swc-multi-project/relay.config.js new file mode 100644 index 0000000000000..10af186bc62cb --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/relay.config.js @@ -0,0 +1,19 @@ +module.exports = { + root: './', + sources: { + 'project-a/pages': 'project-a', + 'project-b/pages': 'project-b', + }, + projects: { + 'project-a': { + schema: 'schema.graphql', + language: 'typescript', + output: '__generated__', + }, + 'project-b': { + schema: 'schema.graphql', + language: 'typescript', + output: '__generated__', + }, + }, +} diff --git a/test/integration/relay-graphql-swc-multi-project/schema.graphql b/test/integration/relay-graphql-swc-multi-project/schema.graphql new file mode 100644 index 0000000000000..7428cd8c20588 --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/schema.graphql @@ -0,0 +1,3 @@ +type Query { + greeting: String! +} diff --git a/test/integration/relay-graphql-swc-multi-project/test/index.test.js b/test/integration/relay-graphql-swc-multi-project/test/index.test.js new file mode 100644 index 0000000000000..605f06c875279 --- /dev/null +++ b/test/integration/relay-graphql-swc-multi-project/test/index.test.js @@ -0,0 +1,89 @@ +/* eslint-env jest */ +import { join } from 'path' +import { execSync } from 'child_process' +import { + findPort, + killApp, + launchApp, + nextBuild, + nextStart, + renderViaHTTP, +} from 'next-test-utils' + +let app +let appPort +const projectAAppDir = join(__dirname, '../project-a') +const projectBAppDir = join(__dirname, '../project-b') + +const runTests = (project) => { + it('should resolve index page correctly', async () => { + const html = await renderViaHTTP(appPort, '/') + expect(html).toContain(project) + expect(html).toContain(`Hello, World!`) + }) +} + +const runRelayCompiler = () => { + // Relay expects the current directory to contain a relay.json + // This ensures the CWD is the one with relay.json since running + // the relay-compiler through yarn would make the root of the repo the CWD. + execSync('../../../node_modules/relay-compiler/cli.js', { + cwd: './test/integration/relay-graphql-swc-multi-project', + }) +} + +describe('Relay Compiler Transform - Multi Project Config', () => { + beforeAll(() => { + runRelayCompiler() + }) + + describe('dev mode', () => { + describe('project-a', () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(projectAAppDir, appPort, { cwd: projectAAppDir }) + }) + + afterAll(() => killApp(app)) + + runTests('Project A') + }) + + describe('project-b', () => { + beforeAll(async () => { + appPort = await findPort() + app = await launchApp(projectBAppDir, appPort, { cwd: projectBAppDir }) + }) + + afterAll(() => killApp(app)) + + runTests('Project B') + }) + }) + + describe('production mode', () => { + describe('project-a', () => { + beforeAll(async () => { + await nextBuild(projectAAppDir, [], { cwd: projectAAppDir }) + appPort = await findPort() + app = await nextStart(projectAAppDir, appPort) + }) + + afterAll(() => killApp(app)) + + runTests('Project A') + }) + + describe('project-b', () => { + beforeAll(async () => { + await nextBuild(projectBAppDir, [], { cwd: projectBAppDir }) + appPort = await findPort() + app = await nextStart(projectBAppDir, appPort) + }) + + afterAll(() => killApp(app)) + + runTests('Project B') + }) + }) +}) diff --git a/test/integration/relay-graphql-swc-single-project/__generated__/pagesQuery.graphql.ts b/test/integration/relay-graphql-swc-single-project/__generated__/pagesQuery.graphql.ts new file mode 100644 index 0000000000000..3963e412c6151 --- /dev/null +++ b/test/integration/relay-graphql-swc-single-project/__generated__/pagesQuery.graphql.ts @@ -0,0 +1,63 @@ +/** + * @generated SignedSource<<187ead9fb6e7b26d71c9161bda6ab902>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest, Query } from 'relay-runtime' +export type pagesQuery$variables = {} +export type pagesQueryVariables = pagesQuery$variables +export type pagesQuery$data = { + readonly greeting: string +} +export type pagesQueryResponse = pagesQuery$data +export type pagesQuery = { + variables: pagesQueryVariables + response: pagesQuery$data +} + +const node: ConcreteRequest = (function () { + var v0 = [ + { + alias: null, + args: null, + kind: 'ScalarField', + name: 'greeting', + storageKey: null, + }, + ] + return { + fragment: { + argumentDefinitions: [], + kind: 'Fragment', + metadata: null, + name: 'pagesQuery', + selections: v0 /*: any*/, + type: 'Query', + abstractKey: null, + }, + kind: 'Request', + operation: { + argumentDefinitions: [], + kind: 'Operation', + name: 'pagesQuery', + selections: v0 /*: any*/, + }, + params: { + cacheID: '167b6de16340efeb876a7787c90e7cec', + id: null, + metadata: {}, + name: 'pagesQuery', + operationKind: 'query', + text: 'query pagesQuery {\n greeting\n}\n', + }, + } +})() + +;(node as any).hash = '4017856344f36f61252354e2eb442d98' + +export default node diff --git a/test/integration/relay-graphql-swc-single-project/next.config.js b/test/integration/relay-graphql-swc-single-project/next.config.js new file mode 100644 index 0000000000000..7e32b6ae09cdc --- /dev/null +++ b/test/integration/relay-graphql-swc-single-project/next.config.js @@ -0,0 +1,5 @@ +module.exports = { + experimental: { + relay: true, + }, +} diff --git a/test/integration/relay-graphql-swc-single-project/pages/api/query.ts b/test/integration/relay-graphql-swc-single-project/pages/api/query.ts new file mode 100644 index 0000000000000..5ad51e06bc09b --- /dev/null +++ b/test/integration/relay-graphql-swc-single-project/pages/api/query.ts @@ -0,0 +1,12 @@ +import { NextApiRequest, NextApiResponse } from 'next' + +export default function handler( + req: NextApiRequest, + res: NextApiResponse<{ data: { greeting: string } }> +) { + res.status(200).json({ + data: { + greeting: 'Hello, World!', + }, + }) +} diff --git a/test/integration/relay-graphql-swc-single-project/pages/index.tsx b/test/integration/relay-graphql-swc-single-project/pages/index.tsx new file mode 100644 index 0000000000000..5b586d43dbd96 --- /dev/null +++ b/test/integration/relay-graphql-swc-single-project/pages/index.tsx @@ -0,0 +1,63 @@ +import { + Environment, + FetchFunction, + fetchQuery, + graphql, + Network, + RecordSource, + Store, +} from 'relay-runtime' +import { GetServerSideProps } from 'next' +import { pagesQuery } from '../__generated__/pagesQuery.graphql' + +type Props = { greeting: string } + +export default function Index({ greeting }: Props) { + return

{greeting}

+} + +function createGraphQLFetcher(host: string | undefined): FetchFunction { + return async function fetchGraphQL(params, variables) { + const url = host ? `http://${host}/api/query` : `/api/query` + + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + query: params.text, + variables, + }), + }) + + return await response.json() + } +} + +export const getServerSideProps: GetServerSideProps = async ({ req }) => { + const environment = new Environment({ + store: new Store(new RecordSource({}), {}), + network: Network.create(createGraphQLFetcher(req.headers.host)), + }) + + const result = await fetchQuery( + environment, + graphql` + query pagesQuery { + greeting + } + `, + {} + ).toPromise() + + if (!result) { + throw new Error( + 'Mock GraphQL Server network request finished without a response!' + ) + } + + return { + props: { greeting: result.greeting }, + } +} diff --git a/test/integration/relay-graphql-swc-single-project/relay.config.js b/test/integration/relay-graphql-swc-single-project/relay.config.js new file mode 100644 index 0000000000000..f01ef1932d212 --- /dev/null +++ b/test/integration/relay-graphql-swc-single-project/relay.config.js @@ -0,0 +1,6 @@ +module.exports = { + src: 'pages', + schema: './schema.graphql', + artifactDirectory: './__generated__', + language: 'typescript', +} diff --git a/test/integration/relay-graphql-swc-single-project/schema.graphql b/test/integration/relay-graphql-swc-single-project/schema.graphql new file mode 100644 index 0000000000000..7428cd8c20588 --- /dev/null +++ b/test/integration/relay-graphql-swc-single-project/schema.graphql @@ -0,0 +1,3 @@ +type Query { + greeting: String! +} diff --git a/test/integration/relay-graphql-swc-single-project/test/index.test.js b/test/integration/relay-graphql-swc-single-project/test/index.test.js new file mode 100644 index 0000000000000..0b19183047878 --- /dev/null +++ b/test/integration/relay-graphql-swc-single-project/test/index.test.js @@ -0,0 +1,57 @@ +/* eslint-env jest */ +import { join } from 'path' +import { execSync } from 'child_process' +import { + findPort, + killApp, + launchApp, + nextBuild, + nextStart, + renderViaHTTP, +} from 'next-test-utils' + +let app +let appPort +const appDir = join(__dirname, '../') + +const runTests = () => { + it('should resolve index page correctly', async () => { + const html = await renderViaHTTP(appPort, '/') + expect(html).toContain('Hello, World!') + }) +} + +const runRelayCompiler = () => { + // Relay expects the current directory to contain a relay.json + // This ensures the CWD is the one with relay.json since running + // the relay-compiler through yarn would make the root of the repo the CWD. + execSync('../../../node_modules/relay-compiler/cli.js', { + cwd: './test/integration/relay-graphql-swc-single-project', + }) +} + +describe('Relay Compiler Transform - Single Project Config', () => { + describe('dev mode', () => { + beforeAll(async () => { + runRelayCompiler() + appPort = await findPort() + app = await launchApp(appDir, appPort, { cwd: appDir }) + }) + afterAll(() => killApp(app)) + + runTests() + }) + + describe('production mode', () => { + beforeAll(async () => { + runRelayCompiler() + await nextBuild(appDir, [], { cwd: appDir }) + appPort = await findPort() + app = await nextStart(appDir, appPort) + }) + + afterAll(() => killApp(app)) + + runTests() + }) +}) diff --git a/test/integration/relay-graphql-swc-single-project/tsconfig.json b/test/integration/relay-graphql-swc-single-project/tsconfig.json new file mode 100644 index 0000000000000..a247e53e341ed --- /dev/null +++ b/test/integration/relay-graphql-swc-single-project/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "esModuleInterop": true, + "module": "esnext", + "jsx": "preserve", + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true + }, + "exclude": ["node_modules"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"] +} diff --git a/yarn.lock b/yarn.lock index b376efc5417db..86bef3f03fd49 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2260,6 +2260,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.0.0": + version "7.16.7" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.7.tgz#03ff99f64106588c9c403c6ecb8c3bafbbdff1fa" + integrity sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/runtime@^7.10.2": version "7.12.13" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.13.tgz#0a21452352b02542db0ffb928ac2d3ca7cb6d66d" @@ -4794,6 +4801,11 @@ "@types/prop-types" "*" csstype "^2.2.0" +"@types/relay-runtime@13.0.0": + version "13.0.0" + resolved "https://registry.yarnpkg.com/@types/relay-runtime/-/relay-runtime-13.0.0.tgz#d0009275522ff826f2e4dab40419f2db58417ecf" + integrity sha512-yzv6F8EZPWA2rtfFP2qMluS8tsz1q4lfdYxLegCshdAjX5uqxTR2pAliATj9wrzD6OMZF4fl9aU+Y+zmSfm2EA== + "@types/resolve@1.17.1": version "1.17.1" resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" @@ -7850,6 +7862,13 @@ cross-fetch@3.0.6, cross-fetch@^3.0.6: dependencies: node-fetch "2.6.1" +cross-fetch@^3.0.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39" + integrity sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ== + dependencies: + node-fetch "2.6.1" + cross-spawn-async@^2.1.1: version "2.2.5" resolved "https://registry.yarnpkg.com/cross-spawn-async/-/cross-spawn-async-2.2.5.tgz#845ff0c0834a3ded9d160daca6d390906bb288cc" @@ -9720,6 +9739,24 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" +fbjs-css-vars@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/fbjs-css-vars/-/fbjs-css-vars-1.0.2.tgz#216551136ae02fe255932c3ec8775f18e2c078b8" + integrity sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ== + +fbjs@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.2.tgz#dfae08a85c66a58372993ce2caf30863f569ff94" + integrity sha512-qv+boqYndjElAJHNN3NoM8XuwQZ1j2m3kEvTgdle8IDjr6oUbkEpvABWtj/rQl3vq4ew7dnElBxL4YJAwTVqQQ== + dependencies: + cross-fetch "^3.0.4" + fbjs-css-vars "^1.0.0" + loose-envify "^1.0.0" + object-assign "^4.1.0" + promise "^7.1.1" + setimmediate "^1.0.5" + ua-parser-js "^0.7.30" + fd-slicer@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" @@ -11419,6 +11456,13 @@ interpret@^2.2.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== +invariant@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + ip@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" @@ -13379,7 +13423,7 @@ longest-streak@^2.0.0: resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4" integrity sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg== -loose-envify@^1.1.0, loose-envify@^1.4.0: +loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" dependencies: @@ -16615,6 +16659,13 @@ promise@8.0.1: dependencies: asap "~2.0.3" +promise@^7.1.1: + version "7.3.1" + resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" + integrity sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg== + dependencies: + asap "~2.0.3" + prompts@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.1.0.tgz#bf90bc71f6065d255ea2bdc0fe6520485c1b45db" @@ -17345,6 +17396,20 @@ rehype-retext@^2.0.1: dependencies: hast-util-to-nlcst "^1.0.0" +relay-compiler@13.0.1: + version "13.0.1" + resolved "https://registry.yarnpkg.com/relay-compiler/-/relay-compiler-13.0.1.tgz#09c713647aa7e1d8cf3de9f7fb4ee6a76b32cf26" + integrity sha512-C/qJ7IdfZ140b9JaNpuAP6WhV/Odt/tIq4sUZoTwsaOlhs+1Zu3fvIOoWKTnZT5PC6krRuw1hD7GSX6/paVpTQ== + +relay-runtime@13.0.1: + version "13.0.1" + resolved "https://registry.yarnpkg.com/relay-runtime/-/relay-runtime-13.0.1.tgz#7e59a07c3b4e8c58d04bc94f6f978822d4128ffb" + integrity sha512-n/+J8PFfLFPVUcz9OG/z2i+adnfk0INwlTkVTw0V6KJe9NI9plc5eRCJwzzwspT4pdCkis5Lcjzvzp4H+0zn8g== + dependencies: + "@babel/runtime" "^7.0.0" + fbjs "^3.0.2" + invariant "^2.2.4" + release@6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/release/-/release-6.3.0.tgz#bbd351d7460948f1ed55ea02b4b2393f98a1637a" @@ -18103,7 +18168,7 @@ set-value@^2.0.0, set-value@^2.0.1: is-plain-object "^2.0.3" split-string "^3.0.1" -setimmediate@1.0.5, setimmediate@^1.0.4: +setimmediate@1.0.5, setimmediate@^1.0.4, setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= @@ -19751,6 +19816,11 @@ ua-parser-js@0.7.28: resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.28.tgz#8ba04e653f35ce210239c64661685bf9121dec31" integrity sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g== +ua-parser-js@^0.7.30: + version "0.7.31" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6" + integrity sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ== + uglify-js@^3.1.4: version "3.7.3" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.7.3.tgz#f918fce9182f466d5140f24bb0ff35c2d32dcc6a"