-
Notifications
You must be signed in to change notification settings - Fork 13
feat(@netlify/vite-plugin-react-router): add edge support #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
serhalp
merged 26 commits into
main
from
serhalp/frb-1519-support-edge-rendering-with-react-router-7
Nov 5, 2025
Merged
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b552eb6
feat(vite-plugin-react-router): add edge support
serhalp 0286e3c
test: add RR7 prerender tests
serhalp 2f24fb1
fix: add mechanism to support user NFs
serhalp 596e1d6
chore(deps): upgrade to latest netlify-cli
serhalp 9f930c9
ci: install supported deno version to de-flake tests
serhalp 78d1afe
test: de-flake on-demand revalidation tests
serhalp 6b91c38
fix: simplify unnecessary edge vite config
serhalp dfb7f5b
refactor: extract shared edge/origin handler code
serhalp 9790bd6
test: fix incorrect assertion
serhalp a512374
test: de-flake cache tests by isolating retries
serhalp f672e85
refactor: clean up minor gunk
serhalp db17f6c
test: fix edge cache assertion again
serhalp e5d9436
test: assert purge calls succeed
serhalp 9ba3231
build: disable in-suite parallelization
serhalp ee4f0b4
build: add publint npm package validation
serhalp c6d75cb
fix: rework edge vs. serverless code organization
serhalp 8f54892
fix: actually include human friendly name on Function
serhalp e30660a
ci: fix new publint workflow
serhalp f726914
build: allow code ESM splitting
serhalp 6a26dd9
Revert "fix: actually include human friendly name on Function"
serhalp eb018ee
build: fix build setup regression
serhalp 47dd051
test: fix RR7 edge fixture
serhalp 3beb85c
fix: backport fix from 2f24fb1 to @netlify/remix-edge-adapter
serhalp 4d68d17
Merge branch 'main' into serhalp/frb-1519-support-edge-rendering-with…
serhalp 4b56e4d
Revert "build: disable in-suite parallelization"
serhalp f2fa84d
test: remove tiny cruft from fixture
serhalp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Publint | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| branches: | ||
| - '**' | ||
| - '!release-please--**' | ||
| merge_group: | ||
| jobs: | ||
| publint: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - run: git config --global core.symlinks true | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
| - run: corepack enable pnpm | ||
| - name: Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: lts/* | ||
| cache: 'pnpm' | ||
| - name: Install Deno | ||
| uses: denoland/setup-deno@v2 | ||
| with: | ||
| # Should satisfy the `DENO_VERSION_RANGE` from https://github.com/netlify/edge-bundler/blob/main/node/bridge.ts#L17 | ||
| deno-version: v2.2.4 | ||
| - name: Install dependencies | ||
| run: pnpm install | ||
| - name: Build | ||
| run: pnpm run build:packages | ||
| - name: Publint | ||
| run: pnpm run --filter '@netlify/*' publint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| export type { GetLoadContextFunction, RequestHandler } from './server' | ||
| export { createRequestHandler, netlifyRouterContext } from './server' | ||
| // All these `function-handler` exports are here for backwards compatibility. Now that we have separate exports | ||
| // for Function and Edge Functions, we should remove these exports in a future major version. | ||
| export type { GetLoadContextFunction, RequestHandler } from './runtimes/netlify-functions' | ||
| // Also, we never documented the `createRequestHandler` export, which has a very niche intended use case, and is not | ||
| // needed for the Edge Functions exports, so we should remove it as well. | ||
| export { createRequestHandler, netlifyRouterContext } from './runtimes/netlify-functions' | ||
|
|
||
| export { netlifyPlugin as default } from './plugin' |
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File extracted as-is. Only change is the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import type { AppLoadContext } from 'react-router' | ||
| import { type RouterContext, createContext, RouterContextProvider } from 'react-router' | ||
|
|
||
| /** | ||
| * A function that returns the value to use as `context` in route `loader` and `action` functions. | ||
| * | ||
| * You can think of this as an escape hatch that allows you to pass environment/platform-specific | ||
| * values through to your loader/action. | ||
| * | ||
| * NOTE: v7.9.0 introduced a breaking change when the user opts in to `future.v8_middleware`. This | ||
| * requires returning an instance of `RouterContextProvider` instead of a plain object. We have a | ||
| * peer dependency on >=7.9.0 so we can safely *import* these, but we cannot assume the user has | ||
| * opted in to the flag. | ||
| */ | ||
| export type GetLoadContextFunction<TNetlifyContext> = | ||
| | (( | ||
| request: Request, | ||
| context: TNetlifyContext, | ||
| ) => Promise<RouterContextProvider> | RouterContextProvider) | ||
| | ((request: Request, context: TNetlifyContext) => Promise<AppLoadContext> | AppLoadContext) | ||
|
|
||
| /** | ||
| * Creates a RouterContext that provides access to Netlify request context. | ||
| * Uses a Proxy to always read from the current `Netlify.context` value, which is always | ||
| * contextual to the in-flight request. | ||
| * | ||
| * @example context.get(netlifyRouterContext).geo?.country?.name | ||
| */ | ||
| export function createNetlifyRouterContext<TNetlifyContext>(): RouterContext< | ||
| Partial<TNetlifyContext> | ||
| > { | ||
| // We must use a singleton because Remix contexts rely on referential equality. | ||
| // We can't hook into the request lifecycle in dev mode, so we use a Proxy to always read from the | ||
| // current `Netlify.context` value, which is always contextual to the in-flight request. | ||
| return createContext<Partial<TNetlifyContext>>( | ||
| new Proxy( | ||
| // Can't reference `Netlify.context` here because it isn't set outside of a request lifecycle | ||
| {}, | ||
| { | ||
| get(_target, prop, receiver) { | ||
| return Reflect.get(Netlify.context ?? {}, prop, receiver) | ||
| }, | ||
| set(_target, prop, value, receiver) { | ||
| return Reflect.set(Netlify.context ?? {}, prop, value, receiver) | ||
| }, | ||
| has(_target, prop) { | ||
| return Reflect.has(Netlify.context ?? {}, prop) | ||
| }, | ||
| deleteProperty(_target, prop) { | ||
| return Reflect.deleteProperty(Netlify.context ?? {}, prop) | ||
| }, | ||
| ownKeys(_target) { | ||
| return Reflect.ownKeys(Netlify.context ?? {}) | ||
| }, | ||
| getOwnPropertyDescriptor(_target, prop) { | ||
| return Reflect.getOwnPropertyDescriptor(Netlify.context ?? {}, prop) | ||
| }, | ||
| }, | ||
| ), | ||
| ) | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identical to the Cloudflare one in the RR7 codebase... https://github.com/remix-run/react-router/blob/cb9a090316003988ff367bb2f2d1ef5bd03bd3af/integration/helpers/vite-plugin-cloudflare-template/app/entry.server.tsx