Skip to content

Add rwsdk (RedwoodJS SDK) support to @navita/vite-plugin#72

Merged
Zn4rK merged 4 commits intomainfrom
copilot/add-rwsdk-support
Jan 22, 2026
Merged

Add rwsdk (RedwoodJS SDK) support to @navita/vite-plugin#72
Zn4rK merged 4 commits intomainfrom
copilot/add-rwsdk-support

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

  • Create src/rwsdk.ts - Main rwsdk plugin implementation following the pattern in remix.ts
  • Update package.json - Add export configuration for @navita/vite-plugin/rwsdk
  • Build and verify the package compiles correctly
  • Run code review and security checks
  • Add documentation at documentation/200-integrations/240-rwsdk.md
  • Add changeset for version bump

Summary

This PR adds support for rwsdk (RedwoodJS SDK), a Cloudflare Workers-based SSR framework with a unique build architecture involving client build, worker build, and linker pass.

The new navitaRwsdk() function:

  • Wraps the base navita plugin
  • Adds a renderChunk hook that runs during the linker pass (detected via RWSDK_BUILD_PASS=linker env var and worker environment)
  • Reads the client manifest at dist/client/.vite/manifest.json to find the navita CSS hashed filename
  • Replaces /virtual:navita.css and virtual:navita.css references in the worker bundle with the actual hashed path

Usage

import { defineConfig } from "vite";
import { redwood } from "rwsdk/vite";
import { cloudflare } from "@cloudflare/vite-plugin";
import { navitaRwsdk } from "@navita/vite-plugin/rwsdk";

export default defineConfig({
  plugins: [
    navitaRwsdk(),
    cloudflare({ viteEnvironment: { name: "worker" } }),
    redwood(),
  ],
});
Original prompt

Feature Request: Add rwsdk (RedwoodJS SDK) Support to @navita/vite-plugin

Background

rwsdk is a Cloudflare Workers-based SSR framework. It has a unique build architecture:

  1. Client build: Standard Vite client build that outputs assets to dist/client/
  2. Worker build: Server-side worker bundle that renders React components
  3. Linker pass: A special build pass (RWSDK_BUILD_PASS=linker) that processes the worker bundle and
    replaces asset placeholders with hashed paths from the client manifest

The Problem

The base navita plugin works correctly for the client build - CSS is emitted and registered in the
Vite manifest at dist/client/.vite/manifest.json. However, when users reference the CSS in their
Document component (the HTML shell), the /virtual:navita.css path isn't replaced with the hashed
filename in the worker bundle.

rwsdk has a built-in Stylesheets component that should handle this via manifest lookup, but it has a
bug where paths don't match (/src/client.tsx vs src/client.tsx). Until that's fixed upstream,
navita needs to handle the replacement directly.

Solution

Create a new rwsdk.ts export similar to remix.ts that:

  1. Wraps the base navita plugin
  2. Adds a renderChunk hook that runs during the linker pass
  3. Reads the client manifest to find the navita CSS hashed filename
  4. Replaces /virtual:navita.css and virtual:navita.css references in the worker bundle

Implementation Reference

Here's a working implementation tested in a real rwsdk project:

// rwsdk.ts
import * as fsp from "node:fs/promises";
import * as path from "node:path";
import { Plugin } from "vite";
import { navita, Options, VIRTUAL_MODULE_ID } from "./index.mjs";

export function navitaRwsdk(options?: Options): Plugin[] {
let projectRootDir: string;
let base: string;

const navitaPlugin = navita(options);                                                             
                                                                                                  
return [                                                                                          
  navitaPlugin,                                    ...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

🦋 Changeset detected

Latest commit: 9a560b2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@navita/vite-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI changed the title [WIP] Add rwsdk support to @navita/vite-plugin Add rwsdk (RedwoodJS SDK) support to @navita/vite-plugin Jan 22, 2026
Copilot AI requested a review from Zn4rK January 22, 2026 15:49
@Zn4rK Zn4rK marked this pull request as ready for review January 22, 2026 15:52
@Zn4rK
Copy link
Contributor

Zn4rK commented Jan 22, 2026

@copilot Add documentation. Look at "documentation/200-integrations/250-remix.md" and create "240-rwsdk.md"

@Zn4rK
Copy link
Contributor

Zn4rK commented Jan 22, 2026

@copilot Add a changeset as well.

Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot Add documentation. Look at "documentation/200-integrations/250-remix.md" and create "240-rwsdk.md"

Added documentation at documentation/200-integrations/240-rwsdk.md following the same format as the Remix documentation. It covers installation, setup, usage in Document.tsx, how the plugin works with rwsdk's build architecture, and configuration options. (c9cf6d4)

Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot Add a changeset as well.

Added changeset at .changeset/add-rwsdk-support.md with a minor version bump for @navita/vite-plugin. (9a560b2)

Copilot AI requested a review from Zn4rK January 22, 2026 15:59
@Zn4rK Zn4rK merged commit 6d2749f into main Jan 22, 2026
2 checks passed
@Zn4rK Zn4rK deleted the copilot/add-rwsdk-support branch January 22, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants