Skip to content

Commit 482d1ed

Browse files
jtydhr88github-actions[bot]
authored andcommitted
fix: normalize path separators in comfyAPIPlugin for Windows compatibility (#7087)
## 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 <img width="720" height="208" alt="image" src="https://github.com/user-attachments/assets/45b9a6e1-f35e-473d-af29-9e181bbe24eb" /> ┆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)
1 parent c8a1df3 commit 482d1ed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

build/plugins/comfyAPIPlugin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ export function comfyAPIPlugin(isDev: boolean): Plugin {
8888

8989
if (result.exports.length > 0) {
9090
const projectRoot = process.cwd()
91-
const relativePath = path.relative(path.join(projectRoot, 'src'), id)
91+
const relativePath = path
92+
.relative(path.join(projectRoot, 'src'), id)
93+
.replace(/\\/g, '/')
9294
const shimFileName = relativePath.replace(/\.ts$/, '.js')
9395

9496
let shimContent = `// Shim for ${relativePath}\n`
9597

96-
const fileKey = relativePath.replace(/\.ts$/, '').replace(/\\/g, '/')
98+
const fileKey = relativePath.replace(/\.ts$/, '')
9799
const warningMessage = getWarningMessage(fileKey, shimFileName)
98100

99101
if (warningMessage) {

0 commit comments

Comments
 (0)