Skip to content

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

Merged
merged 12 commits into from
Mar 11, 2025
13 changes: 10 additions & 3 deletions packages/inference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"exports": {
"types": "./dist/src/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
".": {
"types": "./dist/src/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
},
"browser": {
"./src/snippets/index.js": false,
"./dist/index.js": "./dist/browser/index.js",
"./dist/index.mjs": "./dist/browser/index.mjs"
},
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/inference/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export { InferenceClient, InferenceClientEndpoint, HfInference } from "./Inferen
export { InferenceOutputError } from "./lib/InferenceOutputError";
export * from "./types";
export * from "./tasks";

import * as snippets from "./snippets/index.js";

export { snippets };
23 changes: 23 additions & 0 deletions packages/inference/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Options } from "tsup";

const baseConfig: Options = {
entry: ["./index.ts"],
format: ["cjs", "esm"],
outDir: "dist",
clean: true,
};

const nodeConfig: Options = {
...baseConfig,
platform: "node",
};

const browserConfig: Options = {
...baseConfig,
platform: "browser",
target: "es2018",
splitting: true,
outDir: "dist/browser",
};

export default [nodeConfig, browserConfig];
Loading