@@ -16,6 +16,8 @@ import {
1616const styleUpdateEvent = ( fileId : string ) =>
1717 `vanilla-extract-style-update:${ fileId } ` ;
1818
19+ const virtualPrefix = 'virtual:vanilla-extract:' ;
20+
1921interface Options {
2022 identifiers ?: IdentifierOption ;
2123}
@@ -56,15 +58,16 @@ export function vanillaExtractPlugin({ identifiers }: Options = {}): Plugin {
5658 packageInfo = getPackageInfo ( config . root ) ;
5759 } ,
5860 resolveId ( id ) {
59- if ( id . indexOf ( virtualExt ) > 0 ) {
61+ if ( id . indexOf ( virtualPrefix ) === 0 ) {
6062 return id ;
6163 }
6264 } ,
6365 load ( id ) {
64- const extensionIndex = id . indexOf ( virtualExt ) ;
65-
66- if ( extensionIndex > 0 ) {
67- const fileScopeId = id . substring ( 0 , extensionIndex ) ;
66+ if ( id . indexOf ( virtualPrefix ) === 0 ) {
67+ const fileScopeId = id . slice (
68+ virtualPrefix . length ,
69+ id . indexOf ( virtualExt ) ,
70+ ) ;
6871
6972 if ( ! cssMap . has ( fileScopeId ) ) {
7073 throw new Error ( `Unable to locate ${ fileScopeId } in the CSS map.` ) ;
@@ -132,7 +135,7 @@ export function vanillaExtractPlugin({ identifiers }: Options = {}): Plugin {
132135 identifiers ?? ( config . mode === 'production' ? 'short' : 'debug' ) ,
133136 serializeVirtualCssPath : ( { fileScope, source } ) => {
134137 const fileId = stringifyFileScope ( fileScope ) ;
135- const id = `${ fileId } ${ virtualExt } ` ;
138+ const id = `${ virtualPrefix } ${ fileId } ${ virtualExt } ` ;
136139
137140 if ( server && cssMap . has ( fileId ) && cssMap . get ( fileId ) !== source ) {
138141 const { moduleGraph } = server ;
0 commit comments