mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
1c4f519e36
## What Ports the Relay `graphql` tagged template transform (babel-plugin-relay / swc_relay) as an individual napi transform, per #24914: - **`crates/oxc_relay`** — the core transform as its own crate (modeled on `oxc_react_compiler`): replaces `graphql` tagged templates with references to relay-compiler artifacts. Definition names are extracted textually like `swc_relay` (equivalent to `\b(fragment|mutation|query|subscription)\s+(\w+)` with `#` comments stripped; hand-rolled scanner, no regex dependency). - **`napi/transform-relay`** (`oxc-transform-relay`) — standalone napi package copied from the `napi/transform-react` template: parse → semantic → relay traverse → codegen. Only `graphql` tags are rewritten; TypeScript/JSX syntax is preserved untouched, so the output composes with any downstream toolchain. ## Options | option | default | behavior | |---|---|---| | `artifactDirectory` | unset | when set, the import path is computed lexically relative to the transformed file (babel-plugin-relay `getRelativeImportPath` semantics — swc emits absolute paths instead); unset → `./__generated__/` next to the file | | `language` | `javascript` | `typescript` imports `Name.graphql.ts`, otherwise `Name.graphql.js` | | `eagerEsModules` | `true` | hoisted default imports (babel-plugin-relay ≥ v17 parity); `false` emits inline `require()` (`@swc/plugin-relay` / Next.js behavior) | A `graphql` tag with no extractable definition name produces an error diagnostic (babel throws; swc silently skips). Not supported, documented in both READMEs: dev-mode artifact hash validation, `jsModuleFormat: "haste"`, `isDevVariableName`, swc's Next.js-specific `projects`/`pagesDir`, and GraphQL document validation. closes #24914 --- Implemented with Claude Code.
55 lines
1.4 KiB
TOML
55 lines
1.4 KiB
TOML
[package]
|
|
name = "oxc_transform_relay_napi"
|
|
version = "0.144.0"
|
|
authors.workspace = true
|
|
categories.workspace = true
|
|
edition.workspace = true
|
|
homepage.workspace = true
|
|
include = ["/src", "build.rs"]
|
|
keywords.workspace = true
|
|
license.workspace = true
|
|
publish = false
|
|
repository.workspace = true
|
|
rust-version.workspace = true
|
|
description.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[lib]
|
|
crate-type = ["cdylib", "lib"]
|
|
test = false
|
|
doctest = false
|
|
|
|
[dependencies]
|
|
oxc = { workspace = true, features = ["full"] }
|
|
oxc_napi = { workspace = true }
|
|
oxc_relay = { workspace = true }
|
|
oxc_sourcemap = { workspace = true, features = ["napi"] }
|
|
|
|
napi = { workspace = true }
|
|
napi-derive = { workspace = true }
|
|
|
|
[target.'cfg(target_os = "macos")'.dependencies]
|
|
mimalloc-safe = { workspace = true, optional = true, features = ["skip_collect_on_exit"] }
|
|
|
|
[target.'cfg(all(target_os = "linux", not(target_arch = "arm"), not(target_arch = "aarch64")))'.dependencies]
|
|
mimalloc-safe = { workspace = true, optional = true, features = [
|
|
"skip_collect_on_exit",
|
|
"local_dynamic_tls",
|
|
] }
|
|
|
|
[target.'cfg(all(target_os = "linux", target_arch = "aarch64"))'.dependencies]
|
|
mimalloc-safe = { workspace = true, optional = true, features = [
|
|
"skip_collect_on_exit",
|
|
"local_dynamic_tls",
|
|
"no_opt_arch",
|
|
] }
|
|
|
|
[build-dependencies]
|
|
napi-build = { workspace = true }
|
|
|
|
[features]
|
|
default = []
|
|
allocator = ["dep:mimalloc-safe"]
|