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

Building library - error #22

Open
smlkdev opened this issue Jan 3, 2025 · 2 comments
Open

Building library - error #22

smlkdev opened this issue Jan 3, 2025 · 2 comments

Comments

@smlkdev
Copy link

smlkdev commented Jan 3, 2025

I tried to build library from the source code to debug it (npm link library to my app):

➜  comfyui-sdk git:(main) ✗ npm run build

> @saintno/comfyui-sdk@0.2.39 build
> bun build.ts

JSCompiling Building...
JSCompiling Done!
TypeCompiling Building...
src/client.ts(514,32): error TS2345: Argument of type 'Blob | Buffer<ArrayBufferLike>' is not assignable to parameter of type 'Blob'.
  Type 'Buffer<ArrayBufferLike>' is missing the following properties from type 'Blob': size, type, arrayBuffer, bytes, and 4 more.
src/client.ts(557,32): error TS2345: Argument of type 'Blob | Buffer<ArrayBufferLike>' is not assignable to parameter of type 'Blob'.
  Type 'Buffer<ArrayBufferLike>' is missing the following properties from type 'Blob': size, type, arrayBuffer, bytes, and 4 more.
18 | function checkDiagnosticsErrors(diagnostics, failMessage) {
19 |     if (diagnostics.length === 0) {
20 |         return;
21 |     }
22 |     (0, logger_1.errorLog)(ts.formatDiagnostics(diagnostics, formatDiagnosticsHost).trim());
23 |     throw new Error(failMessage);
               ^
error: Compiled with errors
      at checkDiagnosticsErrors (/Users/user123/Workspace/jp/comfyui-sdk/node_modules/dts-bundle-generator/dist/helpers/check-diagnostics-errors.js:23:11)
      at checkProgramDiagnosticsErrors (/Users/user123/Workspace/jp/comfyui-sdk/node_modules/dts-bundle-generator/dist/helpers/check-diagnostics-errors.js:15:5)
      at getDeclarationFiles (/Users/user123/Workspace/jp/comfyui-sdk/node_modules/dts-bundle-generator/dist/compile-dts.js:151:36)
      at compileDts (/Users/user123/Workspace/jp/comfyui-sdk/node_modules/dts-bundle-generator/dist/compile-dts.js:39:22)
      at generateDtsBundle (/Users/user123/Workspace/jp/comfyui-sdk/node_modules/dts-bundle-generator/dist/bundle-generator.js:14:63)
      at /Users/user123/Workspace/jp/comfyui-sdk/build.ts:41:22

Bun v1.1.42 (macOS x64)

It compiled code (.cjs.js, .esm.js, .map) to build dir but without typescript definitions.

@tctien342
Copy link
Collaborator

I use BunJS to compile the project, please install and use bun run build.

@smlkdev
Copy link
Author

smlkdev commented Jan 4, 2025

For me narrowing type by using instanceof does not work.

When I switch from:

comfyui-sdk/src/client.ts

Lines 510 to 514 in c84eadf

if (file instanceof Buffer) {
formData.append("image", new Blob([file]), fileName);
} else {
formData.append("image", file, fileName);
}

to:

if (file instanceof Blob) {
  formData.append("image", file, "mask.png");
} else {
  formData.append("image", new Blob([file]), "mask.png");
}

it compiles fine

npm run build

> @saintno/comfyui-sdk@0.2.39 build
> bun build.ts

JSCompiling Building...
JSCompiling Done!
TypeCompiling Building...
TypeCompiling Done!
Build Build success, take 2738ms
Build Done!

I tried to find out why this happens, but I couldn't find an answer.

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