@@ -55,6 +55,7 @@ import { scanBuildStripPlugin } from './plugins/scan'
5555import { validateImportPlugin } from './plugins/validate-import'
5656import { vitePluginFindSourceMapURL } from './plugins/find-source-map-url'
5757import { parseCssVirtual , toCssVirtual , parseIdQuery } from './plugins/shared'
58+ import { stripLiteral } from 'strip-literal'
5859
5960const isRolldownVite = 'rolldownVersion' in vite
6061
@@ -702,7 +703,7 @@ export default function vitePluginRsc(
702703 if ( ! code . includes ( 'import.meta.viteRsc.loadModule' ) ) return
703704 const { server } = manager
704705 const s = new MagicString ( code )
705- for ( const match of code . matchAll (
706+ for ( const match of stripLiteral ( code ) . matchAll (
706707 / i m p o r t \. m e t a \. v i t e R s c \. l o a d M o d u l e \( ( [ \s \S ] * ?) \) / dg,
707708 ) ) {
708709 const argCode = match [ 1 ] ! . trim ( )
@@ -973,7 +974,7 @@ export default assetsManifest.bootstrapScriptContent;
973974 assert ( this . environment . name !== 'client' )
974975 const output = new MagicString ( code )
975976
976- for ( const match of code . matchAll (
977+ for ( const match of stripLiteral ( code ) . matchAll (
977978 / i m p o r t \s * \. \s * m e t a \s * \. \s * v i t e R s c \s * \. \s * l o a d B o o t s t r a p S c r i p t C o n t e n t \( ( [ \s \S ] * ?) \) / dg,
978979 ) ) {
979980 const argCode = match [ 1 ] ! . trim ( )
@@ -2087,7 +2088,7 @@ function vitePluginRscCss(
20872088 const output = new MagicString ( code )
20882089 let importAdded = false
20892090
2090- for ( const match of code . matchAll (
2091+ for ( const match of stripLiteral ( code ) . matchAll (
20912092 / i m p o r t \. m e t a \. v i t e R s c \. l o a d C s s \( ( [ \s \S ] * ?) \) / dg,
20922093 ) ) {
20932094 const [ start , end ] = match . indices ! [ 0 ] !
0 commit comments