Skip to content

fix: generic env handling - #5810

Closed
schiller-manuel wants to merge 2 commits into
mainfrom
generic-env
Closed

fix: generic env handling#5810
schiller-manuel wants to merge 2 commits into
mainfrom
generic-env

Conversation

@schiller-manuel

@schiller-manuelschiller-manuel commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor
    • Enhanced plugin architecture to support per-environment configuration and compilation
    • Added optional providerEnv setting to customize which environment provides server functionality

@coderabbitai

coderabbitaiBot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

The changes refactor the plugin architecture to support per-environment compilation instead of a single global plugin model. Server function transformation is now configured per environment (client/server), with support for a custom provider environment and configurable runtime directives. Core plugin wiring has been updated to propagate environment metadata throughout the compilation pipeline.

Changes

Cohort / File(s)Summary
Directive Configuration
packages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.ts
Replaced hard-coded 'use server' string with dynamic opts.directive value for runtime directive control.
Per-Environment Server Function Plugin
packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts
Refactored from single global plugin to per-environment factory perEnvServerFnPlugin(). Updated signature to accept environments array; transform and filtering logic now depend on environment.type ('client' | 'server').
Per-Environment Compiler Plugin
packages/start-plugin-core/src/start-compiler-plugin/plugin.ts
Refactored from single Plugin return to per-environment PluginOption via perEnvCompilerPlugin(). Updated signature to accept environments; introduced centralized transformFilter constant; environment-specific lifecycle hooks and compilation output.
Core Plugin Wiring
packages/start-plugin-core/src/plugin.ts
Added optional providerEnv?: string to server function options; introduced dynamic environments list with custom provider environment augmentation; updated calls to startCompilerPlugin() and createServerFnPlugin() to propagate environments; updated provider environment resolution to use providerEnv fallback.

Sequence Diagram

sequenceDiagram
autonumber
actor User
participant Core as Core Plugin
participant Compiler as Compiler Plugin
participant ServerFn as ServerFn Plugin
User->>Core: Create with environments
activate Core
Note over Core: Prepare environments list<br/>(client, server, optional providerEnv)
Core->>Compiler: createPlugin({ framework, environments })
activate Compiler
Compiler->>Compiler: perEnvCompilerPlugin() per environment
Note over Compiler: Create env-specific<br/>transform + lifecycle
Compiler-->>Core: PluginOption[] for each env
deactivate Compiler
Core->>ServerFn: createPlugin({ framework, directive, environments })
activate ServerFn
ServerFn->>ServerFn: perEnvServerFnPlugin() per environment
Note over ServerFn: Filter by environment.type<br/>Apply directive dynamically
ServerFn-->>Core: PluginOption[] for each env
deactivate ServerFn
Core-->>User: All plugins registered
deactivate Core
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Signature changes: createServerFnPlugin() and startCompilerPlugin() now require environments parameter—verify all call sites are updated and environment metadata is correct.
  • Per-environment logic: Review environment-specific filtering in both compiler and server-fn plugins to ensure transform rules apply to the correct environment type.
  • Provider environment handling: Verify providerEnv fallback logic and ensure custom provider environments are properly added to the environments list without duplication.
  • Plugin lifecycle hooks: Confirm applyToEnvironment conditions and environment-specific transform filters are correctly scoped per environment.
  • Directive propagation: Trace the dynamic directive from opts.directive through handleCreateServerFn() to ensure it replaces the hard-coded string consistently.

Possibly related PRs

Poem

🐰 Per-environment we hop today,
Where directives dance and plugins play,
No more one-size-for-all in sight,
Each client-server flow feels right!
✨ Environments guide the way.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch generic-env

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b75808 and 1fcdd98.

📒 Files selected for processing (4)
  • packages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.ts (1 hunks)
  • packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts (6 hunks)
  • packages/start-plugin-core/src/plugin.ts (4 hunks)
  • packages/start-plugin-core/src/start-compiler-plugin/plugin.ts (2 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloudBot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 1fcdd98

CommandStatusDurationResult
nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded6m 27sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded17sView ↗

☁️ Nx Cloud last updated this comment at 2025-11-10 23:34:15 UTC

@schiller-manuel
schiller-manuel deleted the generic-env branch November 10, 2025 23:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@schiller-manuel