From 1b30880e6c53cad98dd5b33fb67a481d2196beb0 Mon Sep 17 00:00:00 2001 From: Terry Jia Date: Mon, 1 Dec 2025 22:15:44 -0500 Subject: [PATCH] fix: normalize path separators in comfyAPIPlugin for Windows compatibility (#7087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Normalize the path separators by replacing all backslashes with forward slashes before using relativePath Root Cause In build/plugins/comfyAPIPlugin.ts, the path.relative() function generates relative paths that contain backslashes on Windows (e.g., scripts\ui.ts). When this path is directly embedded into a JavaScript string literal, the \u sequence is interpreted as the start of a Unicode escape sequence, causing the SyntaxError: Invalid Unicode escape sequence error ## Screenshots previous error image ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7087-fix-normalize-path-separators-in-comfyAPIPlugin-for-Windows-compatibility-2bd6d73d365081cb88c1c6a0f168a5b5) by [Unito](https://www.unito.io) --- build/plugins/comfyAPIPlugin.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/plugins/comfyAPIPlugin.ts b/build/plugins/comfyAPIPlugin.ts index 3e9a9e5b9..1a3b8d93d 100644 --- a/build/plugins/comfyAPIPlugin.ts +++ b/build/plugins/comfyAPIPlugin.ts @@ -88,12 +88,14 @@ export function comfyAPIPlugin(isDev: boolean): Plugin { if (result.exports.length > 0) { const projectRoot = process.cwd() - const relativePath = path.relative(path.join(projectRoot, 'src'), id) + const relativePath = path + .relative(path.join(projectRoot, 'src'), id) + .replace(/\\/g, '/') const shimFileName = relativePath.replace(/\.ts$/, '.js') let shimContent = `// Shim for ${relativePath}\n` - const fileKey = relativePath.replace(/\.ts$/, '').replace(/\\/g, '/') + const fileKey = relativePath.replace(/\.ts$/, '') const warningMessage = getWarningMessage(fileKey, shimFileName) if (warningMessage) {