Skip to content

Commit 2295bab

Browse files
christian-byrnegithub-actions
andcommitted
fix(collect-i18n-node-defs): refactor to run ComfyNodeDefImpl only in browser context (#5775)
The `collect-i18n-node-defs.ts` script started failing ~3 weeks ago when Vue nodes were introduced ([commit 006e6bd](006e6bd57), [PR #4263](#4263)). The issue stems from: 1. **Import chain bringing Vue components into Node.js context:** ``` collect-i18n-node-defs.ts ↓ imports ComfyNodeDefImpl (from nodeDefStore.ts) ↓ imports useSubgraphStore (from subgraphStore.ts) ↓ transitively imports executionStore.ts ↓ imports ChatHistoryWidget.vue (Vue component!) ``` 2. **TypeScript `declare` fields causing Babel errors:** ``` TypeScript 'declare' fields must first be transformed by @babel/plugin-transform-typescript ``` - Adds custom Babel plugins and configurations - Implements automatic browser globals injection - Requires **47,517 additions, 9,469 deletions** - Modifies the entire Playwright babel transformation pipeline - Uses dynamic imports to defer module loading until runtime - Avoids Babel compilation of problematic TypeScript/Vue files - **Only 40 lines changed** in a single file - No configuration changes needed ```typescript // Instead of static import that Babel tries to compile: // import { ComfyNodeDefImpl } from '../src/stores/nodeDefStore' // We use: // 1. Type-only import (erased at runtime) import type { ComfyNodeDefImpl } from '../src/stores/nodeDefStore' // 2. Dynamic import at runtime (bypasses Babel) const { ComfyNodeDefImpl: ComfyNodeDefImplClass } = await import( '../src/stores/nodeDefStore' ) ``` --------- Co-authored-by: github-actions <[email protected]>
1 parent df3060b commit 2295bab

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

eslint.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ export default defineConfig([
3333
},
3434
parserOptions: {
3535
parser: tseslint.parser,
36-
projectService: true,
36+
projectService: {
37+
allowDefaultProject: [
38+
'vite.config.mts',
39+
'vite.electron.config.mts',
40+
'vite.types.config.mts',
41+
'playwright.config.ts',
42+
'playwright.i18n.config.ts',
43+
'scripts/collect-i18n-node-defs.ts'
44+
]
45+
},
3746
tsConfigRootDir: import.meta.dirname,
3847
ecmaVersion: 2020,
3948
sourceType: 'module',

playwright.i18n.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default defineConfig({
77
headless: true
88
},
99
reporter: 'list',
10+
workers: 1,
1011
timeout: 60000,
1112
testMatch: /collect-i18n-.*\.ts/
1213
})

scripts/collect-i18n-node-defs.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
import * as fs from 'fs'
22

3+
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
4+
35
import { comfyPageFixture as test } from '../browser_tests/fixtures/ComfyPage'
4-
import type { ComfyNodeDef } from '../src/schemas/nodeDefSchema'
5-
import type { ComfyApi } from '../src/scripts/api'
6-
import { ComfyNodeDefImpl } from '../src/stores/nodeDefStore'
6+
import type { ComfyNodeDefImpl } from '../src/stores/nodeDefStore'
77
import { normalizeI18nKey } from '../src/utils/formatUtil'
88

99
const localePath = './src/locales/en/main.json'
1010
const nodeDefsPath = './src/locales/en/nodeDefs.json'
1111

1212
test('collect-i18n-node-defs', async ({ comfyPage }) => {
1313
// Mock view route
14-
comfyPage.page.route('**/view**', async (route) => {
14+
await comfyPage.page.route('**/view**', async (route) => {
1515
await route.fulfill({
1616
body: JSON.stringify({})
1717
})
1818
})
1919

20-
const nodeDefs: ComfyNodeDefImpl[] = (
21-
Object.values(
22-
await comfyPage.page.evaluate(async () => {
23-
const api = window['app'].api as ComfyApi
24-
return await api.getNodeDefs()
25-
})
26-
) as ComfyNodeDef[]
20+
// Note: Don't mock the object_info API endpoint - let it hit the actual backend
21+
22+
const nodeDefs: ComfyNodeDefImpl[] = await comfyPage.page.evaluate(
23+
async () => {
24+
const api = window['app'].api
25+
const rawNodeDefs = await api.getNodeDefs()
26+
const { ComfyNodeDefImpl } = await import('../src/stores/nodeDefStore')
27+
28+
return (
29+
Object.values(rawNodeDefs)
30+
// Ignore DevTools nodes (used for internal testing)
31+
.filter((def: ComfyNodeDef) => !def.name.startsWith('DevTools'))
32+
.map((def: ComfyNodeDef) => new ComfyNodeDefImpl(def))
33+
)
34+
}
2735
)
28-
// Ignore DevTools nodes (used for internal testing)
29-
.filter((def) => !def.name.startsWith('DevTools'))
30-
.map((def) => new ComfyNodeDefImpl(def))
3136

3237
console.log(`Collected ${nodeDefs.length} node definitions`)
3338

0 commit comments

Comments
 (0)