Skip to content

Commit

Permalink
Fix crash on load when not using cjs output (#497)
Browse files Browse the repository at this point in the history
* Fix crash on load when not using cjs output

toDesktop auto update calls use CommonJS require().

* Fix invalid filename
  • Loading branch information
webfiltered authored Dec 17, 2024
1 parent cdd31f1 commit 5cb8b14
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion builder-debug.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const debugConfig: Configuration = {
{ from: './assets/uv/uvx', to: 'uv/uvx' },
{ from: './assets/UI', to: 'UI' },
],
beforeBuild: './scripts/preMake.cjs',
beforeBuild: './scripts/preMake.js',
win: {
icon: './assets/UI/Comfy_Logo.ico',
target: 'zip',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "0.3.34",
"homepage": "https://comfy.org",
"description": "The best modular GUI to run AI diffusion models.",
"main": ".vite/build/main.js",
"main": ".vite/build/main.cjs",
"packageManager": "[email protected]",
"type": "module",
"config": {
Expand Down
12 changes: 6 additions & 6 deletions scripts/preMake.cjs → scripts/preMake.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { exec, execSync, spawnSync, spawn } = require("child_process");
const path = require("path");
const os = require('os');
const process = require("process");
const fs = require('fs-extra');
import { exec, execSync, spawnSync, spawn } from "child_process"
import path from "path"
import * as os from 'os'
import process from "process"
import fs from 'fs-extra'

module.exports = async ({ appOutDir, packager, outDir }) => {
export default async ({ appOutDir, packager, outDir }) => {

const firstInstallOnToDesktopServers =
process.env.TODESKTOP_CI && process.env.TODESKTOP_INITIAL_INSTALL_PHASE;
Expand Down
2 changes: 1 addition & 1 deletion src/main-process/appWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AppWindow {
x: storedX,
y: storedY,
webPreferences: {
preload: path.join(import.meta.dirname, '../build/preload.cjs'),
preload: path.join(__dirname, '../build/preload.cjs'),
nodeIntegration: true,
contextIsolation: true,
webviewTag: true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"jsx": "react",
"target": "ESNext",
"module": "ES2022",
"module": "ESNext",
"allowJs": true,
"strict": true,
"skipLibCheck": true,
Expand Down
4 changes: 2 additions & 2 deletions vite.main.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default defineConfig((env) => {
outDir: '.vite/build',
lib: {
entry: './src/main.ts',
fileName: () => '[name].js',
formats: ['es'],
fileName: (_format, name) => `${name}.cjs`,
formats: ['cjs'],
},
rollupOptions: {
external,
Expand Down

0 comments on commit 5cb8b14

Please sign in to comment.