File tree Expand file tree Collapse file tree 5 files changed +20
-205
lines changed
Expand file tree Collapse file tree 5 files changed +20
-205
lines changed Original file line number Diff line number Diff line change 4141 },
4242 "type" : " module" ,
4343 "scripts" : {
44- "build" : " pnpm run export-templates && tshy" ,
45- "dts" : " tsx scripts/generate-dts.ts && tsc --noEmit dist/index.d.ts" ,
44+ "build" : " pnpm run export-templates && pnpm run package-to-ts && tshy" ,
4645 "lint" : " eslint --quiet --fix --ext .cjs,.ts ." ,
4746 "lint:check" : " eslint --ext .cjs,.ts ." ,
4847 "format" : " prettier --write ." ,
5352 "test:browser" : " vitest run --browser.name=chrome --browser.headless --config vitest.config.mts" ,
5453 "check" : " tsc" ,
5554 "dev" : " pnpm run export-templates && tsup src/index.ts --format cjs,esm --watch" ,
56- "export-templates" : " tsx scripts/export-templates.ts"
55+ "export-templates" : " tsx scripts/export-templates.ts" ,
56+ "package-to-ts" : " tsx scripts/package-json-to-ts.ts"
5757 },
5858 "dependencies" : {
5959 "@huggingface/tasks" : " workspace:^" ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { readFileSync , writeFileSync } from "node:fs" ;
2+
3+ const pkg = JSON . parse ( readFileSync ( "./package.json" , "utf8" ) ) ;
4+
5+ const content = [
6+ "// Generated file from package.json. Issues importing JSON directly when publishing on commonjs/ESM - see https://github.com/microsoft/TypeScript/issues/51783" ,
7+ `export const PACKAGE_VERSION = ${ JSON . stringify ( pkg . version ) } ;` ,
8+ `export const PACKAGE_NAME = ${ JSON . stringify ( pkg . name ) } ;` ,
9+ "" ,
10+ ] . join ( "\n" ) ;
11+
12+ writeFileSync ( "./src/package.ts" , content ) ;
Original file line number Diff line number Diff line change 1- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2- // @ts -ignore this works or not depending on commonjs/ESM - see https://github.com/microsoft/TypeScript/issues/51783
3- import pkg from "../../package.json" with { type : "json" } ;
41import { HF_HEADER_X_BILL_TO , HF_HUB_URL } from "../config.js" ;
2+ import { PACKAGE_NAME , PACKAGE_VERSION } from "../package.js" ;
53import type { InferenceTask , Options , RequestArgs } from "../types.js" ;
64import type { InferenceProviderModelMapping } from "./getInferenceProviderMapping.js" ;
75import { getInferenceProviderMapping } from "./getInferenceProviderMapping.js" ;
@@ -160,7 +158,7 @@ export function makeRequestOptionsFromResolvedModel(
160158
161159 // Add user-agent to headers
162160 // e.g. @huggingface /inference/3.1.3
163- const ownUserAgent = `${ pkg . name } /${ pkg . version } ` ;
161+ const ownUserAgent = `${ PACKAGE_NAME } /${ PACKAGE_VERSION } ` ;
164162 const userAgent = [ ownUserAgent , typeof navigator !== "undefined" ? navigator . userAgent : undefined ]
165163 . filter ( ( x ) => x !== undefined )
166164 . join ( " " ) ;
Original file line number Diff line number Diff line change 1+ // Generated file from package.json. Issues importing JSON directly when publishing on commonjs/ESM - see https://github.com/microsoft/TypeScript/issues/51783
2+ export const PACKAGE_VERSION = "3.13.2" ;
3+ export const PACKAGE_NAME = "@huggingface/inference" ;
You can’t perform that action at this time.
0 commit comments