Skip to content

Commit a02081f

Browse files
committed
fix: problems for windows
1 parent d0cbb8d commit a02081f

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

packages/cli/flight-server-transform-plugin/src/lib.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,16 @@ where
8181
C: Comments,
8282
{
8383
fn new(filename: String, comments: Option<C>, app_dir: String, runtime_path: String) -> Self {
84-
let path = PathBuf::from(&filename);
85-
let app_dir_path = PathBuf::from(&app_dir);
84+
let app_dir = app_dir.replace('\\', "/");
85+
let filename = filename.replace('\\', "/");
8686

87-
let relative_path = path.strip_prefix(&app_dir_path)
88-
.map(|p| p.to_path_buf().to_slash_lossy().into_owned())
89-
.unwrap_or_else(|_| filename);
87+
let app_dir = app_dir.trim_end_matches('/');
88+
89+
let relative_path = if filename.starts_with(&app_dir) {
90+
filename[app_dir.len()..].trim_start_matches('/')
91+
} else {
92+
&filename
93+
}.to_string();
9094

9195
Self {
9296
directive: None,

tests/integration/rsc-ssr-app/modern.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export default applyBaseConfig({
1212
},
1313
rsc: true,
1414
},
15+
output: {
16+
minify: false,
17+
},
1518
// source: {
1619
// alias: {
1720
// react: path.dirname(require.resolve('react')),

tests/integration/rsc-ssr-app/src/server-component-root/App.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ import styles from './App.module.less';
44
import Suspended from './Suspended';
55
import { Counter } from './components/Counter';
66
import { getCountState } from './components/ServerState';
7+
// import { increment } from './components/action';
8+
9+
// export async function greeting() {
10+
// 'use server';
11+
// increment(6);
12+
// }
713

814
const App = ({ name }: { name: string }) => {
915
const countStateFromServer = getCountState();
1016
return (
1117
<div className={styles.root}>
1218
<h1 data-testid="app-name">{name}</h1>
19+
{/* <form action={greeting}>
20+
<button type="submit">Greeting</button>
21+
</form> */}
1322
<Suspense fallback={<div>Loading...</div>}>
1423
<Suspended />
1524
</Suspense>

tests/integration/rsc-ssr-app/src/server-component-root/components/action.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export async function increment(num: number) {
1414

1515
export async function incrementByForm(prevResult: number, formData: FormData) {
1616
const count = formData.get('count');
17-
const newCount = prevResult + Number(count);
17+
const currentNum = getCountState();
18+
const newCount = currentNum + Number(count);
1819
setCountState(newCount);
1920
return newCount;
2021
}

0 commit comments

Comments
 (0)