diff --git a/package-lock.json b/package-lock.json index 84cff3aac..bcf85ea03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "litegraph.js", - "version": "0.7.36", + "version": "0.7.42", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "litegraph.js", - "version": "0.7.36", + "version": "0.7.42", "license": "MIT", "devDependencies": { "@types/jest": "^28.1.3", diff --git a/package.json b/package.json index ae812ff1e..91181e351 100755 --- a/package.json +++ b/package.json @@ -1,10 +1,20 @@ { "name": "@comfyorg/litegraph", - "version": "0.7.36", + "version": "0.7.42", "type": "module", "description": "A graph node editor similar to PD or UDK Blueprints. It works in an HTML5 Canvas and allows to export graphs to be included in applications.", - "main": "src/litegraph.js", - "types": "src/litegraph.d.ts", + "main": "./dist/litegraph.umd.js", + "module": "./dist/litegraph.es.js", + "types": "./dist/litegraph.d.ts", + "style": "./dist/css/litegraph.css", + "exports": { + ".": { + "import": "./dist/litegraph.es.js", + "require": "./dist/litegraph.umd.js", + "types": "./dist/litegraph.d.ts" + }, + "./style.css": "./dist/css/litegraph.css" + }, "directories": { "doc": "doc" }, diff --git a/public/src/litegraph.d.ts b/public/litegraph.d.ts similarity index 100% rename from public/src/litegraph.d.ts rename to public/litegraph.d.ts diff --git a/src/litegraph.js b/src/litegraph.js index dd617d52e..31456f12f 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -1,4 +1,6 @@ +const globalExport = {}; +(function (globalThis) { // ************************************************************* // LiteGraph CLASS ******* // ************************************************************* @@ -14513,14 +14515,13 @@ LGraphNode.prototype.executeAction = function(action) window.setTimeout(callback, 1000 / 60); }; } +})(globalExport) -if (typeof exports != "undefined") { - exports.LiteGraph = globalThis.LiteGraph; - exports.LGraph = globalThis.LGraph; - exports.LLink = globalThis.LLink; - exports.LGraphNode = globalThis.LGraphNode; - exports.LGraphGroup = globalThis.LGraphGroup; - exports.DragAndScale = globalThis.DragAndScale; - exports.LGraphCanvas = globalThis.LGraphCanvas; - exports.ContextMenu = globalThis.ContextMenu; -} +export const LiteGraph = globalExport.LiteGraph; +export const LGraph = globalExport.LGraph; +export const LLink = globalExport.LLink; +export const LGraphNode = globalExport.LGraphNode; +export const LGraphGroup = globalExport.LGraphGroup; +export const DragAndScale = globalExport.DragAndScale; +export const LGraphCanvas = globalExport.LGraphCanvas; +export const ContextMenu = globalExport.ContextMenu; diff --git a/vite.config.mts b/vite.config.mts index 6ff64e248..98adda288 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -6,16 +6,10 @@ export default defineConfig({ lib: { entry: path.resolve(__dirname, 'src/litegraph.js'), name: 'litegraph.js', - // TODO: Below workaround ensures output matches pre-vite format. Should be removed. - fileName: (moduleFormat, entryAlias) => 'src/litegraph.js', - formats: ['iife'] + fileName: (format) => `litegraph.${format}.js`, + formats: ['es', 'umd'] }, minify: false, sourcemap: true, - rollupOptions: { - // Disabling tree-shaking - // Prevent vite remove unused exports - treeshake: false - } }, }) \ No newline at end of file