@@ -18,7 +18,7 @@ import { assets_base, find_deps } from './build/utils.js';
1818import { dev } from './dev/index.js' ;
1919import { is_illegal , module_guard , normalize_id } from './graph_analysis/index.js' ;
2020import { preview } from './preview/index.js' ;
21- import { get_config_aliases , get_env } from './utils.js' ;
21+ import { get_config_aliases , get_env , strip_virtual_prefix } from './utils.js' ;
2222import { write_client_manifest } from '../../core/sync/write_client_manifest.js' ;
2323import prerender from '../../core/postbuild/prerender.js' ;
2424import analyse from '../../core/postbuild/analyse.js' ;
@@ -336,7 +336,7 @@ function kit({ svelte_config }) {
336336 async resolveId ( id ) {
337337 // treat $env/static/[public|private] as virtual
338338 if ( id . startsWith ( '$env/' ) || id . startsWith ( '__sveltekit/' ) || id === '$service-worker' ) {
339- return `\0 ${ id } ` ;
339+ return `\0virtual: ${ id } ` ;
340340 }
341341 } ,
342342
@@ -358,24 +358,24 @@ function kit({ svelte_config }) {
358358 } )
359359 ) {
360360 const relative = normalize_id ( id , normalized_lib , normalized_cwd ) ;
361- throw new Error ( `Cannot import ${ relative } into client-side code` ) ;
361+ throw new Error ( `Cannot import ${ strip_virtual_prefix ( relative ) } into client-side code` ) ;
362362 }
363363 }
364364
365365 switch ( id ) {
366- case '\0 $env/static/private' :
366+ case '\0virtual: $env/static/private' :
367367 return create_static_module ( '$env/static/private' , env . private ) ;
368368
369- case '\0 $env/static/public' :
369+ case '\0virtual: $env/static/public' :
370370 return create_static_module ( '$env/static/public' , env . public ) ;
371371
372- case '\0 $env/dynamic/private' :
372+ case '\0virtual: $env/dynamic/private' :
373373 return create_dynamic_module (
374374 'private' ,
375375 vite_config_env . command === 'serve' ? env . private : undefined
376376 ) ;
377377
378- case '\0 $env/dynamic/public' :
378+ case '\0virtual: $env/dynamic/public' :
379379 // populate `$env/dynamic/public` from `window`
380380 if ( browser ) {
381381 return `export const env = ${ global } .env;` ;
@@ -386,12 +386,12 @@ function kit({ svelte_config }) {
386386 vite_config_env . command === 'serve' ? env . public : undefined
387387 ) ;
388388
389- case '\0 $service-worker' :
389+ case '\0virtual: $service-worker' :
390390 return create_service_worker_module ( svelte_config ) ;
391391
392392 // for internal use only. it's published as $app/paths externally
393393 // we use this alias so that we won't collide with user aliases
394- case '\0__sveltekit /paths' : {
394+ case '\0virtual:__sveltekit /paths' : {
395395 const { assets, base } = svelte_config . kit . paths ;
396396
397397 // use the values defined in `global`, but fall back to hard-coded values
@@ -429,7 +429,7 @@ function kit({ svelte_config }) {
429429 ` ;
430430 }
431431
432- case '\0__sveltekit /environment' : {
432+ case '\0virtual:__sveltekit /environment' : {
433433 const { version } = svelte_config . kit ;
434434
435435 return dedent `
0 commit comments