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

Raise if not node #1259

Open
wants to merge 2 commits into
base: templated-inference-python-snippets
Choose a base branch
from

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Mar 7, 2025

⚠️ PR opened on top of #1255

Related to this thread #1255 (comment).

@coyotte508 @SBrandeis @julien-c WDYT? 🙈

for the record, I'm looking for a solution where:

  1. we keep this public/open-source
  2. we keep the structure of jinja templates
  3. ideally no new package in hf.js
  4. ideally no new tooling (e.g. to translate jinja into TS code)

Solution here is simply to gracefully raise an error if environment not supported.

@coyotte508
Copy link
Member

coyotte508 commented Mar 7, 2025

hm you should go the @huggingface/hub way, for functions like download-file-to-cache-dir

They have this section:

"browser": {
"./src/utils/sha256-node.ts": false,
"./src/utils/FileBlob.ts": false,
"./src/lib/cache-management.ts": false,
"./src/lib/download-file-to-cache-dir.ts": false,
"./src/lib/snapshot-download.ts": false,
"./dist/index.js": "./dist/browser/index.js",
"./dist/index.mjs": "./dist/browser/index.mjs"
},
and the tsup config https://github.com/huggingface/huggingface.js/blob/5cd51b9901f173d286148531a41cd1193f76b74a/packages/hub/tsup.config.ts#L1-L24

Then you can export snippets only for non-browser context

I think otherwise you'll still have issues importing node packages even if you don't use them, for versions of the lib released on the CDNs

@Wauplin
Copy link
Contributor Author

Wauplin commented Mar 7, 2025

I'll look into it, thanks @coyotte508 !

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

Successfully merging this pull request may close these issues.

2 participants