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

Fix ghost dependency onnxruntime-common with versions for node and web #1088

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"homepage": "https://github.com/huggingface/transformers.js#readme",
"dependencies": {
"@huggingface/jinja": "^0.3.2",
"onnxruntime-common-for-node": "npm:[email protected]",
"onnxruntime-common-for-web": "npm:[email protected]",
"onnxruntime-node": "1.20.1",
"onnxruntime-web": "1.21.0-dev.20241205-d27fecd3d3",
"sharp": "^0.33.5"
Expand All @@ -75,6 +77,14 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
},
"overrides": {
"onnxruntime-node": {
"onnxruntime-common": "$onnxruntime-common-for-node"
},
"onnxruntime-web": {
"onnxruntime-common": "$onnxruntime-common-for-web"
}
},
"files": [
"src",
"dist",
Expand All @@ -87,7 +97,8 @@
"path": false,
"url": false,
"sharp": false,
"onnxruntime-node": false
"onnxruntime-node": false,
"onnxruntime-common-for-node": false
},
"publishConfig": {
"access": "public"
Expand Down
5 changes: 4 additions & 1 deletion src/backends/onnx.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import { env, apis } from '../env.js';
import * as ONNX_NODE from 'onnxruntime-node';
import * as ONNX_WEB from 'onnxruntime-web';

export { Tensor } from 'onnxruntime-common';
import { Tensor as Tensor_NODE } from "onnxruntime-common-for-node";
import { Tensor as Tensor_WEB } from "onnxruntime-common-for-web";
let Tensor = apis.IS_NODE_ENV ? Tensor_NODE : Tensor_WEB;
export { Tensor };

/**
* @typedef {import('onnxruntime-common').InferenceSession.ExecutionProviderConfig} ONNXExecutionProviders
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@ function buildConfig({

// Do not bundle onnxruntime-web when packaging for Node.js.
// Instead, we use the native library (onnxruntime-node).
const NODE_IGNORE_MODULES = ["onnxruntime-web"];
const NODE_IGNORE_MODULES = ["onnxruntime-web", "onnxruntime-common-for-web"];

// Do not bundle the following modules with webpack (mark as external)
// NOTE: This is necessary for both type="module" and type="commonjs",
// and will be ignored when building for web (only used for node/deno)
const NODE_EXTERNAL_MODULES = [
"onnxruntime-node",
"onnxruntime-common-for-node",
"sharp",
"fs",
"path",
Expand Down