@@ -131,7 +131,7 @@ export async function getWidgetHTML(
131131
132132 if ( isViteDevServer ) {
133133 const vite = viteHandle . devServer ;
134- const virtualModuleId = `virtual:chatgpt-widget-${ widgetName } .html` ;
134+ const virtualModuleId = `virtual:chatgpt-widget-html- ${ widgetName } .html` ;
135135
136136 // Step 1: Use plugin container to resolve and load the raw HTML from our plugin
137137 const resolved = await vite . pluginContainer . resolveId ( virtualModuleId ) ;
@@ -152,8 +152,8 @@ export async function getWidgetHTML(
152152 // Pass the virtual module ID as the URL so Vite knows the context
153153 const transformedHtml = await vite . transformIndexHtml ( virtualModuleId , rawHtml ) ;
154154
155- // rewrite src="virtual:chatgpt-widget-${widgetName}.js" to src="/@id/virtual:chatgpt-widget-${widgetName}.js"
156- html = transformedHtml . replace ( / s r c = " v i r t u a l : c h a t g p t - w i d g e t - / g, `src="/@id/virtual:chatgpt-widget-` ) ;
155+ // rewrite src="virtual:chatgpt-widget-entrypoint- ${widgetName}.js" to src="/@id/virtual:chatgpt-widget-entrypoint -${widgetName}.js"
156+ html = transformedHtml . replace ( / s r c = " v i r t u a l : c h a t g p t - w i d g e t - e n t r y p o i n t - / g, `src="/@id/virtual:chatgpt-widget-entrypoint -` ) ;
157157
158158 const plugin = vite . config . plugins . find ( ( plugin ) => plugin . name === PLUGIN_NAME ) as ChatGPTWidgetPlugin ;
159159 // Get explicit baseUrl from the plugin in the plugin options
@@ -210,7 +210,7 @@ export async function getWidgetHTML(
210210 const manifest = JSON . parse ( manifestContent ) as Record < string , { file : string } > ;
211211
212212 // Look for the widget HTML file in the manifest
213- const virtualModuleId = `virtual:chatgpt-widget-${ widgetName } .html` ;
213+ const virtualModuleId = `virtual:chatgpt-widget-html- ${ widgetName } .html` ;
214214 const manifestEntry = manifest [ virtualModuleId ] ;
215215
216216 if ( ! manifestEntry ) {
@@ -271,7 +271,7 @@ export function generateWidgetEntrypointHTML(widgetName: string): string {
271271 // Always use the virtual: protocol here
272272 // In dev mode, the MCP helper will rewrite this to /@id/virtual: after HTML transformation
273273 // In build mode, Vite will resolve and bundle this appropriately
274- const jsEntrypoint = `virtual:chatgpt-widget-${ widgetName } .js` ;
274+ const jsEntrypoint = `virtual:chatgpt-widget-entrypoint- ${ widgetName } .js` ;
275275
276276 return `
277277<!DOCTYPE html>
@@ -339,7 +339,7 @@ export function chatGPTWidgetPlugin(options: ChatGPTWidgetPluginOptions = {}): C
339339 const widgetEntries : Record < string , string > = { } ;
340340
341341 for ( const file of files ) {
342- widgetEntries [ `chatgpt-widget-${ file . name } ` ] = `virtual:chatgpt-widget-${ file . name } .html` ;
342+ widgetEntries [ `chatgpt-widget-${ file . name } ` ] = `virtual:chatgpt-widget-html- ${ file . name } .html` ;
343343 }
344344
345345 // Add widget entries to existing input
@@ -362,26 +362,26 @@ export function chatGPTWidgetPlugin(options: ChatGPTWidgetPluginOptions = {}): C
362362
363363 resolveId ( id ) {
364364 // Handle virtual HTML entrypoint resolution
365- if ( id . startsWith ( "virtual:chatgpt-widget-" ) && id . endsWith ( ".html" ) ) {
365+ if ( id . startsWith ( "virtual:chatgpt-widget-html- " ) && id . endsWith ( ".html" ) ) {
366366 return id ;
367367 }
368368 // Handle virtual JS entrypoint resolution
369- if ( id . startsWith ( "virtual:chatgpt-widget-" ) && id . endsWith ( ".js" ) ) {
369+ if ( id . startsWith ( "virtual:chatgpt-widget-entrypoint- " ) && id . endsWith ( ".js" ) ) {
370370 return "\0" + id ;
371371 }
372372 return null ;
373373 } ,
374374
375375 async load ( id ) {
376376 // Handle virtual HTML files
377- if ( id . startsWith ( "virtual:chatgpt-widget-" ) && id . endsWith ( ".html" ) ) {
378- const widgetName = id . replace ( "virtual:chatgpt-widget-" , "" ) . replace ( ".html" , "" ) ;
377+ if ( id . startsWith ( "virtual:chatgpt-widget-html- " ) && id . endsWith ( ".html" ) ) {
378+ const widgetName = id . replace ( "virtual:chatgpt-widget-html- " , "" ) . replace ( ".html" , "" ) ;
379379 return generateWidgetEntrypointHTML ( widgetName ) ;
380380 }
381381
382382 // Handle virtual JS entrypoints
383- if ( id . startsWith ( "\0virtual:chatgpt-widget-" ) && id . endsWith ( ".js" ) ) {
384- const widgetName = id . replace ( "\0virtual:chatgpt-widget-" , "" ) . replace ( ".js" , "" ) ;
383+ if ( id . startsWith ( "\0virtual:chatgpt-widget-entrypoint- " ) && id . endsWith ( ".js" ) ) {
384+ const widgetName = id . replace ( "\0virtual:chatgpt-widget-entrypoint- " , "" ) . replace ( ".js" , "" ) ;
385385
386386 // Find the actual widget file
387387 const widgetsDirPath = path . resolve ( config . root , widgetsDir ) ;
0 commit comments