[PR #491] [MERGED] Convert repo from CommonJS to ES Modules #908

Closed
opened 2026-10-31 22:17:56 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/desktop/pull/491
Author: @webfiltered
Created: 12/15/2024
Status: ✅ Merged
Merged: 12/16/2024
Merged by: @huchenlei

Base: main ← Head: esm


📝 Commits (9)

  • 0c10ede Convert package from CommonJS to ES Modules
  • f5e9b11 Fix CommonJS files treated as ESM
  • 62b86b1 Convert CommonJS scripts to ES modules
  • 8b2d5b8 Fix type errors - missing node.js types
  • bbc23ae Remove unnecessary type assertions
  • cfff980 Fix broken imports
  • 45cb61e Rename CommonJS build / test scripts to .cjs
  • e413f83 Fix playwright using cjs require
  • 17deaa4 Fix UV download script - ESM conversion error

📊 Changes

21 files changed (+76 additions, -52 deletions)

View changed files

📝 builder-debug.config.ts (+1 -1)
📝 jest.config.cjs (+0 -0)
📝 package.json (+5 -4)
📝 playwright.config.ts (+1 -1)
📝 scripts/downloadFrontend.js (+7 -5)
📝 scripts/downloadUV.js (+10 -8)
➕ scripts/getPackage.js (+7 -0)
📝 scripts/launchdev.js (+3 -3)
📝 scripts/makeComfy.js (+4 -4)
📝 scripts/preMake.cjs (+0 -0)
📝 scripts/prepareTypes.js (+4 -6)
📝 scripts/releaseTypes.js (+2 -2)
📝 scripts/resetInstall.js (+5 -5)
📝 scripts/todesktop/afterPack.cjs (+0 -0)
📝 scripts/todesktop/beforeInstall.cjs (+0 -0)
📝 scripts/updateFrontend.js (+2 -2)
📝 src/main-process/appWindow.ts (+1 -1)
📝 tsconfig.json (+1 -1)
📝 vite.main.config.ts (+2 -4)
📝 vite.preload.config.ts (+3 -3)

...and 1 more files

📄 Description

  • Converts most CommonJS code into ES Modules
  • preload.ts now compiles to preload.cjs - this is a one-off special case
    • File is still TypeScript, but its transpile format is unchanged - cjs instead of es
    • Electron supports more features and requires less working around to inject this file as CJS
  • Renamed preMake.cjs, which remains as CommonJS - requirement of build process
  • vite config now has full proper typing
  • ESLint and other tooling can be installed 🎉

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/desktop/pull/491 **Author:** [@webfiltered](https://github.com/webfiltered) **Created:** 12/15/2024 **Status:** ✅ Merged **Merged:** 12/16/2024 **Merged by:** [@huchenlei](https://github.com/huchenlei) **Base:** `main` ← **Head:** `esm` --- ### 📝 Commits (9) - [`0c10ede`](https://github.com/Comfy-Org/desktop/commit/0c10ede1caedd8731aca17bf95dee655e55ec46d) Convert package from CommonJS to ES Modules - [`f5e9b11`](https://github.com/Comfy-Org/desktop/commit/f5e9b11c487ce9a15d0439f2698f0f8eedfa3690) Fix CommonJS files treated as ESM - [`62b86b1`](https://github.com/Comfy-Org/desktop/commit/62b86b13e0714bab958b332660ecf6ba05bf65e0) Convert CommonJS scripts to ES modules - [`8b2d5b8`](https://github.com/Comfy-Org/desktop/commit/8b2d5b835625c02dfb5bac8b5ca551043d7376e4) Fix type errors - missing node.js types - [`bbc23ae`](https://github.com/Comfy-Org/desktop/commit/bbc23aea94ef38b71ad30327740cfeecb44a2bd4) Remove unnecessary type assertions - [`cfff980`](https://github.com/Comfy-Org/desktop/commit/cfff98025c467bdb66118d62da0f1a6af35beade) Fix broken imports - [`45cb61e`](https://github.com/Comfy-Org/desktop/commit/45cb61e083f12814246d52ab723777874d6b5cbd) Rename CommonJS build / test scripts to .cjs - [`e413f83`](https://github.com/Comfy-Org/desktop/commit/e413f83c6f28186773b8e637b8aac3b4d51392dc) Fix playwright using cjs require - [`17deaa4`](https://github.com/Comfy-Org/desktop/commit/17deaa4877f9ccf0b79dbc2a4d052680a18b81c1) Fix UV download script - ESM conversion error ### 📊 Changes **21 files changed** (+76 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `builder-debug.config.ts` (+1 -1) 📝 `jest.config.cjs` (+0 -0) 📝 `package.json` (+5 -4) 📝 `playwright.config.ts` (+1 -1) 📝 `scripts/downloadFrontend.js` (+7 -5) 📝 `scripts/downloadUV.js` (+10 -8) ➕ `scripts/getPackage.js` (+7 -0) 📝 `scripts/launchdev.js` (+3 -3) 📝 `scripts/makeComfy.js` (+4 -4) 📝 `scripts/preMake.cjs` (+0 -0) 📝 `scripts/prepareTypes.js` (+4 -6) 📝 `scripts/releaseTypes.js` (+2 -2) 📝 `scripts/resetInstall.js` (+5 -5) 📝 `scripts/todesktop/afterPack.cjs` (+0 -0) 📝 `scripts/todesktop/beforeInstall.cjs` (+0 -0) 📝 `scripts/updateFrontend.js` (+2 -2) 📝 `src/main-process/appWindow.ts` (+1 -1) 📝 `tsconfig.json` (+1 -1) 📝 `vite.main.config.ts` (+2 -4) 📝 `vite.preload.config.ts` (+3 -3) _...and 1 more files_ </details> ### 📄 Description - Converts most CommonJS code into ES Modules - `preload.ts` now compiles to `preload.cjs` - this is a one-off special case - File is still TypeScript, but its transpile format is unchanged - `cjs` instead of `es` - Electron [supports more features](https://www.electronjs.org/docs/latest/tutorial/esm#preload-scripts) and requires less working around to inject this file as CJS - Renamed `preMake.cjs`, which remains as CommonJS - requirement of build process - vite config now has full proper typing - **ESLint and other tooling can be installed** 🎉 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 22:17:56 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/desktop#908
No description provided.