File tree 3 files changed +13
-10
lines changed 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change
1
+ import { join , parse } from "node:path" ;
2
+
3
+ export function hashremap ( input : string , hash : string ) {
4
+ const parsed = parse ( input ) ;
5
+ return `${ join ( parsed . dir , parsed . name ) } -${ hash } ${ parsed . ext } ` ;
6
+ }
7
+
8
+ export function generateHashedName ( name : string , hash : Record < string , string > ) {
9
+ return hash [ name ] ? hashremap ( name , hash [ name ] ) : name ;
10
+ }
Original file line number Diff line number Diff line change 1
1
import { FileSystemRouter , type BunFile } from "bun" ;
2
2
import { NJSON } from "next-json" ;
3
3
import { readFileSync , statSync } from "node:fs" ;
4
- import { join , parse , relative } from "node:path" ;
4
+ import { join , relative } from "node:path" ;
5
5
import { renderToReadableStream } from "react-dom/server" ;
6
6
import { ClientOnlyError } from "./client" ;
7
+ import { hashremap } from "./hash" ;
7
8
import { MetaContext , PreloadModule } from "./preload" ;
8
9
9
10
export class StaticRouters {
@@ -225,11 +226,6 @@ function* scanCacheDependencies(
225
226
} catch { }
226
227
}
227
228
228
- function hashremap ( input : string , hash : string ) {
229
- const parsed = parse ( input ) ;
230
- return `${ join ( parsed . dir , parsed . name ) } -${ hash } ${ parsed . ext } ` ;
231
- }
232
-
233
229
export class StaticFileCache {
234
230
#cache = new Map < string , BunFile > ( ) ;
235
231
constructor ( public base : string ) { }
Original file line number Diff line number Diff line change 1
1
import { createContext , use } from "react" ;
2
2
import { preloadModule , type PreloadModuleOptions } from "react-dom" ;
3
+ import { generateHashedName } from "./hash" ;
3
4
4
5
// @ignore
5
6
export const MetaContext = createContext < {
@@ -19,10 +20,6 @@ function* walkDependencies(
19
20
}
20
21
}
21
22
22
- function generateHashedName ( name : string , hash : Record < string , string > ) {
23
- return hash [ name ] ? `${ name } ?${ hash [ name ] } ` : name ;
24
- }
25
-
26
23
export function PreloadModule ( {
27
24
module,
28
25
...options
You can’t perform that action at this time.
0 commit comments