Files
oxc-project__oxc/.github/workflows/prepare_release_crates.yml
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

92 lines
3.4 KiB
YAML

name: Prepare Release Crates
permissions: {}
on:
workflow_dispatch:
schedule:
# Triggers every Monday at 5pm Shanghai time (9am UTC)
- cron: "0 9 * * 1"
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
check:
if: github.repository == 'oxc-project/oxc'
name: Check
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
- uses: oxc-project/setup-rust@3d6fb132fbe7cdcb66bf8ec193911c2945369d12 # v1.0.17
with:
cache-key: warm
tools: cargo-release-oxc
- uses: oxc-project/setup-node@d59b270414aa7d0eed947eed4eb5b0b8a675f01d # v1.4.0
- run: cargo ck
- run: cargo release-oxc publish --release crates --dry-run # zizmor: ignore[use-trusted-publishing]
- name: Check Codegen package
run: |
pnpm --filter oxc-codegen build
pnpm publish packages/codegen --dry-run --provenance --access public --no-git-checks
prepare:
if: github.repository == 'oxc-project/oxc'
name: Prepare Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: oxc-project/setup-rust@3d6fb132fbe7cdcb66bf8ec193911c2945369d12 # v1.0.17
with:
cache-key: warm
tools: cargo-release-oxc
- name: Run
id: run
run: |
cargo ck
cargo release-oxc update --changelog --release crates
echo "CRATES_VERSION=$(cat ./target/CRATES_VERSION)" >> $GITHUB_OUTPUT
- uses: oxc-project/setup-node@d59b270414aa7d0eed947eed4eb5b0b8a675f01d # v1.4.0
# Run NAPI-RS build, because NAPI-RS uses version from `package.json` in the bindings file,
# which is committed to the repo. The version has just been bumped in previous step.
# We don't use the compiled `.node` binary, so only do a development build, as it's faster.
- name: Rebuild NAPI packages bindings
run: |
pnpm --filter oxc-minify run build-dev
pnpm --filter oxc-parser run build-dev
pnpm --filter oxc-transform run build-dev
pnpm --filter oxc-transform-react run build-dev
pnpm --filter oxc-transform-relay run build-dev
- name: Update Cargo.lock
run: cargo check
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
id: app-token
with:
client-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
id: pr
with:
# bot account with PAT required for triggering workflow runs
# See https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs
token: ${{ steps.app-token.outputs.token }}
commit-message: "release(crates): oxc v${{ steps.run.outputs.CRATES_VERSION }}"
title: "release(crates): oxc v${{ steps.run.outputs.CRATES_VERSION }}"
branch: release/crates
branch-suffix: timestamp
base: main
body-path: ./target/CRATES_CHANGELOG
assignees: Boshen
labels: run-monitor-oxc