-
Notifications
You must be signed in to change notification settings - Fork 436
Do not export ./snippets module in browser mode #1259
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
Do not export ./snippets module in browser mode #1259
Conversation
hm you should go the They have this section: huggingface.js/packages/hub/package.json Lines 20 to 28 in 5cd51b9
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 |
I'll look into it, thanks @coyotte508 ! |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
packages/inference/src/index.ts
Outdated
let snippets = {}; | ||
if (typeof window === "undefined") { | ||
snippets = import("./snippets").then((mod) => mod.default); | ||
} | ||
export { snippets }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coyotte508 what would be the best way to do a conditional import here? I haven't found any convincing solution. In @huggingface/hub
it's not really a problem as everything is included using export * from "./lib";
(here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there's an issue? Is there an error when just keeping the code as before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it felt weird to do import * as snippets from "./snippets/index.js";
when we know ./snippets/index.js
might not be in the final package. But looks like tooling is done the correct way so perfect 😄
…ingface.js into raise-if-not-node
Thanks for fixing things @coyotte508 ! Ok to merge it now? (into #1255 I mean) |
yes |
d2579ab
into
templated-inference-python-snippets
Related to this thread #1255 (comment).
@coyotte508 @SBrandeis @julien-c WDYT? 🙈
for the record, I'm looking for a solution where:
Solution here is simply to gracefully raise an error if environment not supported.EDIT: based on #1259 (comment), goal is to not package the
./snippets
module in browser mode.