From bd31793352c2de932c947b9b0b023fb7447ff725 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 11:06:38 +0000 Subject: [PATCH 1/2] Initial plan From 2509283721a9fbee4e6606b38bd0b9486e7c9e2b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 11:12:58 +0000 Subject: [PATCH 2/2] Fix duplicate JavaScript module loading by excluding direct script tags from import map When an HTML file contains `; }, @@ -6778,7 +6781,7 @@ This content is loaded from a markdown file. return htmlContent; }, - replaceAssetReferences(htmlContent, fileSystem, currentFilePath = '', processedHtmlFiles = null) { + replaceAssetReferences(htmlContent, fileSystem, currentFilePath = '', processedHtmlFiles = null, directModuleScripts = null) { if (!processedHtmlFiles) processedHtmlFiles = new Map(); htmlContent = this.assetReplacers.withScriptBlocksPreserved(htmlContent, (safeHtmlContent) => { let updatedHtml = this.assetReplacers.replaceAllConfigBased(safeHtmlContent, fileSystem, currentFilePath); @@ -6801,7 +6804,7 @@ This content is loaded from a markdown file. } const workerFileSet = new Set(workerFileNames); - htmlContent = this.assetReplacers.replaceScriptTags(htmlContent, fileSystem, currentFilePath, workerFileSet); + htmlContent = this.assetReplacers.replaceScriptTags(htmlContent, fileSystem, currentFilePath, workerFileSet, directModuleScripts); return htmlContent; }, @@ -6838,13 +6841,14 @@ This content is loaded from a markdown file. const mainHtmlPath = this.getFileNameFromPanel(mainHtmlFile.id) || 'index.html'; const processedHtmlFiles = new Map(); processedHtmlFiles.set(mainHtmlPath, null); - let processedHtml = this.replaceAssetReferences(mainHtmlFile.editor.getValue(), fileSystem, mainHtmlPath, processedHtmlFiles); + const directModuleScripts = new Set(); + let processedHtml = this.replaceAssetReferences(mainHtmlFile.editor.getValue(), fileSystem, mainHtmlPath, processedHtmlFiles, directModuleScripts); - return this.injectConsoleScript(processedHtml, fileSystem, mainHtmlPath); + return this.injectConsoleScript(processedHtml, fileSystem, mainHtmlPath, directModuleScripts); }, - injectConsoleScript(htmlContent, fileSystem = null, mainHtmlPath = 'index.html') { - const moduleImportMapScript = this.buildModuleImportMapScript(fileSystem); + injectConsoleScript(htmlContent, fileSystem = null, mainHtmlPath = 'index.html', directModuleScripts = null) { + const moduleImportMapScript = this.buildModuleImportMapScript(fileSystem, directModuleScripts); const captureScript = this.consoleBridge.getCaptureScript(fileSystem, mainHtmlPath); const headInjection = [moduleImportMapScript, captureScript].filter(Boolean).join('\n'); @@ -6950,9 +6954,10 @@ This content is loaded from a markdown file. const fileSystem = this.createVirtualFileSystem(); const mainHtmlFile = this.getMainHtmlFile(); const mainHtmlPath = mainHtmlFile ? (this.getFileNameFromPanel(mainHtmlFile.id) || 'index.html') : 'index.html'; - const htmlWithAssets = this.replaceAssetReferences(processedHtml, fileSystem, mainHtmlPath); + const directModuleScripts = new Set(); + const htmlWithAssets = this.replaceAssetReferences(processedHtml, fileSystem, mainHtmlPath, null, directModuleScripts); - const moduleImportMapScript = this.buildModuleImportMapScript(fileSystem); + const moduleImportMapScript = this.buildModuleImportMapScript(fileSystem, directModuleScripts); const moduleScript = this.processModuleFiles(moduleFiles, mainHtmlPath); const jsScript = this.processJavaScriptFiles(jsFiles, mainHtmlPath);