Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refering to uglifyjs in build.py #17

Open
liusida opened this issue Jun 5, 2024 · 5 comments
Open

Refering to uglifyjs in build.py #17

liusida opened this issue Jun 5, 2024 · 5 comments

Comments

@liusida
Copy link

liusida commented Jun 5, 2024

When I try to do npm run build, it fails to find uglifyjs. The error message is attached below:

PS C:\ComfyUI\litegraph\litegraph.js-daniel> npm run build

> @mr_pebble/[email protected] build
> python3 build.py

Processing ./src/litegraph.js Traceback (most recent call last):
  File "C:\ComfyUI\litegraph\litegraph.js-daniel\build.py", line 170, in <module>
    pack_js_files(js_files_list["js_files"], js_files_list["output_filename"])
  File "C:\ComfyUI\litegraph\litegraph.js-daniel\build.py", line 102, in pack_js_files
    minified_js = subprocess.run(["uglifyjs", js_file, "-c"], stdout=subprocess.PIPE, text=True)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\learn\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\learn\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\learn\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

I found explanation that, when use uglifyjs command in package.json's scripts section, it'll automatically search ./node_modules/.bin/ for the executables. However, when we use python file build.py and refer uglifyjs in it, there's no mechanism to include the ./node_modules/.bin/. I guess you didn't see this problem is because you globally installed uglifyjs, and that was used in your npm run build.

And the extension .cmd is also needed for windows, so i think we should add some code for people who are building this on Windows.

I'll do a quick PR to fix this. I am familiar with Python. :)

@liusida
Copy link
Author

liusida commented Jun 5, 2024

I'm afraid that building does not work currently, does it? There are multiple import{LiteGraph}from"./litegraph.js"; in the resulting file litegraph.js...

@liusida
Copy link
Author

liusida commented Jun 5, 2024

Simply concatenating JavaScript files that contain ES6 module imports, which results multiple import { LiteGraph } from "./litegraph.js";, will not work correctly when combined into a single file using a naive concatenation approach. This method doesn't resolve the imports and can lead to issues such as duplicate imports, scope conflicts, and incorrect load order.

We might need to use Webpack for the building process.

@liusida
Copy link
Author

liusida commented Jun 5, 2024

I've integrated webpack to the project, and made two working HTML examples in the examples/ folder showing how to use litegraph with/without the webpack bundle.

Also, npm run build:patch can bump the version by 1 just like your python script did, from 0.10.2 -> 0.10.3. (and npm run build:minor will increase the version to 0.11, and npm run build:major will increase it to 1.0)

I've submitted the code for review.
#19

@daniel-lewis-ab
Copy link
Owner

Thanks man. I do need to go through and fix a few things, including this.

Right now there are two reasons I'm not as active managing this - and it won't be too terribly long until I'm back.

  1. I'm selling my house soon and am rapidly going through renovations (think another week or two)
  2. Comfy's team hasn't pulled yet.

If either of those changes, I'll come back quick to get some things done.

@liusida
Copy link
Author

liusida commented Jun 11, 2024

no problem. hope you are selling it at a great price. xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants