@@ -62,7 +62,7 @@ export async function create_plugin(config, cwd) {
6262 const url = id . startsWith ( '..' ) ? `/@fs${ path . posix . resolve ( id ) } ` : `/${ id } ` ;
6363
6464 const module = /** @type {import('types').SSRComponent } */ (
65- await vite . ssrLoadModule ( url )
65+ await vite . ssrLoadModule ( url , { fixStacktrace : false } )
6666 ) ;
6767 const node = await vite . moduleGraph . getModuleByUrl ( url ) ;
6868
@@ -84,7 +84,7 @@ export async function create_plugin(config, cwd) {
8484 ( query . has ( 'svelte' ) && query . get ( 'type' ) === 'style' )
8585 ) {
8686 try {
87- const mod = await vite . ssrLoadModule ( dep . url ) ;
87+ const mod = await vite . ssrLoadModule ( dep . url , { fixStacktrace : false } ) ;
8888 styles [ dep . url ] = mod . default ;
8989 } catch {
9090 // this can happen with dynamically imported modules, I think
@@ -117,7 +117,7 @@ export async function create_plugin(config, cwd) {
117117 shadow : route . shadow
118118 ? async ( ) => {
119119 const url = path . resolve ( cwd , /** @type {string } */ ( route . shadow ) ) ;
120- return await vite . ssrLoadModule ( url ) ;
120+ return await vite . ssrLoadModule ( url , { fixStacktrace : false } ) ;
121121 }
122122 : null ,
123123 a : route . a . map ( ( id ) => manifest_data . components . indexOf ( id ) ) ,
@@ -133,7 +133,7 @@ export async function create_plugin(config, cwd) {
133133 types,
134134 load : async ( ) => {
135135 const url = path . resolve ( cwd , route . file ) ;
136- return await vite . ssrLoadModule ( url ) ;
136+ return await vite . ssrLoadModule ( url , { fixStacktrace : false } ) ;
137137 }
138138 } ;
139139 } ) ,
@@ -144,7 +144,7 @@ export async function create_plugin(config, cwd) {
144144 for ( const key in manifest_data . matchers ) {
145145 const file = manifest_data . matchers [ key ] ;
146146 const url = path . resolve ( cwd , file ) ;
147- const module = await vite . ssrLoadModule ( url ) ;
147+ const module = await vite . ssrLoadModule ( url , { fixStacktrace : false } ) ;
148148
149149 if ( module . match ) {
150150 matchers [ key ] = module . match ;
@@ -161,20 +161,7 @@ export async function create_plugin(config, cwd) {
161161
162162 /** @param {Error } error */
163163 function fix_stack_trace ( error ) {
164- // TODO https://github.com/vitejs/vite/issues/7045
165-
166- // ideally vite would expose ssrRewriteStacktrace, but
167- // in lieu of that, we can implement it ourselves. we
168- // don't want to mutate the error object, because
169- // the stack trace could be 'fixed' multiple times,
170- // and Vite will fix stack traces before we even
171- // see them if they occur during ssrLoadModule
172- const original = error . stack ;
173- vite . ssrFixStacktrace ( error ) ;
174- const fixed = error . stack ;
175- error . stack = original ;
176-
177- return fixed ;
164+ return error . stack ? vite . ssrRewriteStacktrace ( error . stack ) : error . stack ;
178165 }
179166
180167 update_manifest ( ) ;
@@ -220,7 +207,7 @@ export async function create_plugin(config, cwd) {
220207
221208 /** @type {Partial<import('types').Hooks> } */
222209 const user_hooks = resolve_entry ( config . kit . files . hooks )
223- ? await vite . ssrLoadModule ( `/${ config . kit . files . hooks } ` )
210+ ? await vite . ssrLoadModule ( `/${ config . kit . files . hooks } ` , { fixStacktrace : false } )
224211 : { } ;
225212
226213 const handle = user_hooks . handle || ( ( { event, resolve } ) => resolve ( event ) ) ;
@@ -260,13 +247,15 @@ export async function create_plugin(config, cwd) {
260247 // can get loaded twice via different URLs, which causes failures. Might
261248 // require changes to Vite to fix
262249 const { default : root } = await vite . ssrLoadModule (
263- `/${ posixify ( path . relative ( cwd , `${ config . kit . outDir } /generated/root.svelte` ) ) } `
250+ `/${ posixify ( path . relative ( cwd , `${ config . kit . outDir } /generated/root.svelte` ) ) } ` ,
251+ { fixStacktrace : false }
264252 ) ;
265253
266254 const paths = await vite . ssrLoadModule (
267255 process . env . BUNDLED
268256 ? `/${ posixify ( path . relative ( cwd , `${ config . kit . outDir } /runtime/paths.js` ) ) } `
269- : `/@fs${ runtime } /paths.js`
257+ : `/@fs${ runtime } /paths.js` ,
258+ { fixStacktrace : false }
270259 ) ;
271260
272261 paths . set_paths ( {
0 commit comments