File tree Expand file tree Collapse file tree 5 files changed +198
-1
lines changed
Expand file tree Collapse file tree 5 files changed +198
-1
lines changed Original file line number Diff line number Diff line change 1+ import { test } from '@playwright/test'
2+ import { setupInlineFixture , useFixture } from './fixture'
3+ import { defineStarterTest } from './starter'
4+
5+ test . describe ( ( ) => {
6+ const root = 'examples/e2e/temp/middleware-mode'
7+
8+ test . beforeAll ( async ( ) => {
9+ await setupInlineFixture ( {
10+ src : 'examples/starter' ,
11+ dest : root ,
12+ } )
13+ } )
14+
15+ test . describe ( 'dev-middleware-mode' , ( ) => {
16+ const f = useFixture ( {
17+ root,
18+ mode : 'dev' ,
19+ command : 'node ../../middleware-mode.ts dev' ,
20+ } )
21+ defineStarterTest ( f )
22+ } )
23+
24+ test . describe ( 'build-middleware-mode' , ( ) => {
25+ const f = useFixture ( {
26+ root,
27+ mode : 'build' ,
28+ command : 'node ../../middleware-mode.ts start' ,
29+ cliOptions : {
30+ env : {
31+ NODE_ENV : 'production' ,
32+ } ,
33+ } ,
34+ } )
35+ defineStarterTest ( f )
36+ } )
37+ } )
Original file line number Diff line number Diff line change 1+ import path from 'node:path'
2+ import { pathToFileURL } from 'node:url'
3+ // @ts -ignore
4+ import connect from 'connect'
5+ import { createRequestListener } from '@remix-run/node-fetch-server'
6+ import sirv from 'sirv'
7+ import type { Connect } from 'vite'
8+
9+ async function main ( ) {
10+ const app = connect ( ) as Connect . Server
11+ const command = process . argv [ 2 ]
12+ if ( command === 'dev' ) {
13+ const { createServer } = await import ( 'vite' )
14+ const server = await createServer ( {
15+ clearScreen : false ,
16+ server : { middlewareMode : true } ,
17+ } )
18+ app . use ( server . middlewares )
19+ } else if ( command === 'start' ) {
20+ app . use (
21+ sirv ( './dist/client' , {
22+ etag : true ,
23+ dev : true ,
24+ extensions : [ ] ,
25+ ignores : false ,
26+ } ) ,
27+ )
28+ const entry = await import (
29+ pathToFileURL ( path . resolve ( 'dist/rsc/index.js' ) ) . href
30+ )
31+ app . use ( createRequestListener ( entry . default ) )
32+ } else {
33+ console . error ( `Unknown command: ${ command } ` )
34+ process . exitCode = 1
35+ return
36+ }
37+
38+ const port = process . env . PORT || 3000
39+ app . listen ( port )
40+ console . log ( `Server started at http://localhost:${ port } ` )
41+ }
42+
43+ main ( ) . catch ( ( e ) => {
44+ console . error ( e )
45+ process . exitCode = 1
46+ } )
Original file line number Diff line number Diff line change 55 "devDependencies" : {
66 "@vitejs/plugin-react" : " latest" ,
77 "@vitejs/plugin-rsc" : " latest" ,
8- "babel-plugin-react-compiler" : " 19.1.0-rc.3"
8+ "babel-plugin-react-compiler" : " 19.1.0-rc.3" ,
9+ "connect" : " ^3.7.0" ,
10+ "sirv" : " ^3.0.1"
911 }
1012}
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " ../../tsconfig.base.json" ,
3+ "include" : [" *.ts" ],
4+ "compilerOptions" : {
5+ "noPropertyAccessFromIndexSignature" : false ,
6+ "noImplicitReturns" : false ,
7+ "checkJs" : false ,
8+ "declaration" : true ,
9+ "isolatedDeclarations" : true ,
10+ "jsx" : " react-jsx"
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments