@@ -5,11 +5,10 @@ export default {
55 transform ( code , id ) {
66 const normalizedId = id . replaceAll ( '\\' , '/' ) ;
77
8- if ( normalizedId . endsWith ( '/build/env.js' ) ) {
9- return code . replace (
10- 'path.dirname(fileURLToPath(import.meta.url))' ,
11- "path.resolve(process.cwd(), 'build')" ,
12- ) ;
8+ if ( normalizedId . endsWith ( '/build/adapter-node.js' ) ) {
9+ return code
10+ . replace ( "import { dirname } from 'node:path';" , "import { resolve } from 'node:path';" )
11+ . replace ( 'dirname(fileURLToPath(import.meta.url))' , "resolve(process.cwd(), 'build')" ) ;
1312 }
1413
1514 if ( normalizedId . includes ( '/build/server/' ) ) {
@@ -19,9 +18,19 @@ export default {
1918 // requests and carries the same context without it.
2019 . replaceAll ( '!!globalThis.process?.versions?.webcontainer' , 'true' )
2120 . replaceAll (
22- " import(' node:async_hooks')" ,
21+ / i m p o r t \( ( [ ' " ] ) n o d e : a s y n c _ h o o k s \1 \) / g ,
2322 "Promise.reject(new Error('AsyncLocalStorage is unavailable in this component'))" ,
24- ) ;
23+ )
24+ // jco-std throws for getBuiltinModule. Let SvelteKit's
25+ // optional Node diagnostics use their non-Node fallback.
26+ . replaceAll ( 'globalThis.process?.getBuiltinModule' , 'undefined' )
27+ // Vite retains an unused Node metadata read. Resolving
28+ // import.meta after snapshotting traps in StarlingMonkey.
29+ . replaceAll ( 'import.meta.dirname;' , '' )
30+ // StarlingMonkey lacks this Unicode property escape in
31+ // dynamic regexes. Keep the equivalent range and u flag
32+ // so valid surrogate pairs remain intact when escaping HTML.
33+ . replaceAll ( String . raw `\\p{Surrogate}` , String . raw `[\\uD800-\\uDFFF]` ) ;
2534
2635 // StarlingMonkey does not currently implement
2736 // String.prototype.normalize. SvelteKit's static asset server
0 commit comments