Files
oxc-project__oxc/oxfmtrc.jsonc
Boshen 1c4f519e36 feat(napi): add Relay transform plugin (#25503)
## 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.
2026-08-13 13:56:01 +00:00

49 lines
2.3 KiB
JSON

{
"$schema": "./npm/oxfmt/configuration_schema.json",
"ignorePatterns": [
"**/tests/**",
// Ignore `fixtures` directories except for `apps/oxlint/test/fixtures`
"**/fixtures/**",
"!apps/oxlint/test/fixtures/**",
"apps/oxlint/test/fixtures/bom/files/**",
"apps/oxlint/test/fixtures/fixes/files/**",
"apps/oxlint/test/fixtures/plugin_eslint/files/**",
"apps/oxlint/test/fixtures/suggestions/files/**",
"apps/oxlint/test/fixtures/sourceCode_token_methods/files/**",
"apps/oxlint/test/fixtures/tokens/files/**",
"**/dist/**",
"**/generated/**",
"**/CHANGELOG.md",
"**/*.snap.md",
"apps/oxfmt/conformance/snapshots/**",
"apps/oxlint/conformance/snapshots/**",
"tasks/coverage/node-compat-table",
"tasks/coverage/misc",
"tasks/coverage/src/runtime/babelHelpers.js",
"tasks/transform_conformance/tests",
"apps/{oxlint,oxfmt}/src-js/bindings.js",
"apps/{oxlint,oxfmt}/src-js/bindings.d.ts",
"apps/oxlint/src-js/generated/",
"apps/oxlint/src-js/package/config.generated.ts",
"apps/oxfmt/src-js/config.generated.ts",
"apps/oxlint/conformance/submodules/**",
"napi/parser/src-js/bindings.js",
"tasks/codegen_conformance/index.js",
"tasks/codegen_conformance/index.d.ts",
"napi/playground/playground.wasi-browser.js",
"napi/{transform,transform-react,transform-relay,minify,playground}/index.js",
"napi/{transform,transform-react,transform-relay,minify,playground}/index.d.ts",
"napi/{parser,transform,transform-react,transform-relay,minify,playground}/**/index.d.ts",
"napi/{parser,transform,transform-react,transform-relay,minify,playground}/**/*.wasi.d.cts",
"napi/{parser,transform,transform-react,transform-relay,minify,playground}/**/*.wasi-browser.js",
"napi/{parser,transform,transform-react,transform-relay,minify,playground}/**/*.wasi.cjs",
"napi/{parser,transform,transform-react,transform-relay,minify,playground}/**/wasi-worker-browser.mjs",
"napi/{parser,transform,transform-react,transform-relay,minify,playground}/**/wasi-worker.mjs",
"napi/{parser,transform,transform-react,transform-relay,minify,playground}/**/browser.js",
"npm/runtime/src",
"npm/oxc-types/types.d.ts",
"npm/oxfmt/configuration_schema.json",
"npm/oxlint/configuration_schema.json",
],
}