diff --git a/examples/segment-anything-client/vite.config.js b/examples/segment-anything-client/vite.config.js index 4a405e33b..22ba3e4b5 100644 --- a/examples/segment-anything-client/vite.config.js +++ b/examples/segment-anything-client/vite.config.js @@ -6,13 +6,12 @@ export default defineConfig(env => { } }; - // TODO: Add the following when using onnxruntime-web@1.19.0 - // if (env.mode === 'development') { - // // The .wasm files are not correctly served using Vite in development mode. - // // This is a workaround to exclude the onnxruntime-web package from Vite's optimization. - // // See also: https://github.com/vitejs/vite/issues/8427 - // config.optimizeDeps = { exclude: ["onnxruntime-web"] }; - // } + if (env.mode === 'development') { + // The .wasm files are not correctly served using Vite in development mode. + // This is a workaround to exclude the onnxruntime-web package from Vite's optimization. + // See also: https://github.com/vitejs/vite/issues/8427 + config.optimizeDeps = { exclude: ["onnxruntime-web"] }; + } return config; }); diff --git a/package-lock.json b/package-lock.json index 271e7f2ba..3b0981a3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@huggingface/jinja": "^0.3.0", "onnxruntime-node": "1.18.0", - "onnxruntime-web": "1.18.0", + "onnxruntime-web": "1.19.0-dev.20240804-ee2fe87e2d", "sharp": "^0.33.2" }, "devDependencies": { @@ -6179,18 +6179,23 @@ } }, "node_modules/onnxruntime-web": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/onnxruntime-web/-/onnxruntime-web-1.18.0.tgz", - "integrity": "sha512-o1UKj4ABIj1gmG7ae0RKJ3/GT+3yoF0RRpfDfeoe0huzRW4FDRLfbkDETmdFAvnJEXuYDE0YT+hhkia0352StQ==", + "version": "1.19.0-dev.20240804-ee2fe87e2d", + "resolved": "https://registry.npmjs.org/onnxruntime-web/-/onnxruntime-web-1.19.0-dev.20240804-ee2fe87e2d.tgz", + "integrity": "sha512-uz93GKeBjHHq0150qIAxGGMhf5YLnfh12OChvYyLG2H6LzXymXhorvcxV7sklofw6fVooL3IutMz8nbZLMQxYg==", "dependencies": { "flatbuffers": "^1.12.0", "guid-typescript": "^1.0.9", "long": "^5.2.3", - "onnxruntime-common": "1.18.0", + "onnxruntime-common": "1.19.0-dev.20240730-530a2d7b41", "platform": "^1.3.6", "protobufjs": "^7.2.4" } }, + "node_modules/onnxruntime-web/node_modules/onnxruntime-common": { + "version": "1.19.0-dev.20240730-530a2d7b41", + "resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.19.0-dev.20240730-530a2d7b41.tgz", + "integrity": "sha512-fWyg0USjvdHY5JL+3y/fXUDTOl9OLfhrX+sttfM2LW7jT/O8VNxjc16oAjyJHJruOQdrH2qo+KnxjOLA68i2dw==" + }, "node_modules/open": { "version": "8.4.2", "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", diff --git a/package.json b/package.json index b9024d5b1..0dab49cb6 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "types": "./types/transformers.d.ts", "type": "module", "exports": { - ".": { - "require": "./dist/transformers.cjs", - "import": "./dist/transformers.js" - } + "node": { + "import": "./dist/transformers.js", + "require": "./dist/transformers.cjs" + }, + "default": "./src/transformers.js" }, "scripts": { "format": "prettier --write .", @@ -48,7 +49,7 @@ "dependencies": { "@huggingface/jinja": "^0.3.0", "onnxruntime-node": "1.18.0", - "onnxruntime-web": "1.18.0", + "onnxruntime-web": "1.19.0-dev.20240804-ee2fe87e2d", "sharp": "^0.33.2" }, "devDependencies": { diff --git a/src/backends/onnx.js b/src/backends/onnx.js index 599d95933..2a323075f 100644 --- a/src/backends/onnx.js +++ b/src/backends/onnx.js @@ -105,11 +105,11 @@ const ONNX_ENV = ONNX?.env; if (ONNX_ENV?.wasm) { // Initialize wasm backend with suitable default settings. - // Set path to wasm files. This is needed when running in a web worker. + // (Optional) Set path to wasm files. This is needed when running in a web worker. // https://onnxruntime.ai/docs/api/js/interfaces/Env.WebAssemblyFlags.html#wasmPaths // We use remote wasm files by default to make it easier for newer users. // In practice, users should probably self-host the necessary .wasm files. - ONNX_ENV.wasm.wasmPaths = 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.18.0/dist/'; + // ONNX_ENV.wasm.wasmPaths = 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.19.0-dev.20240804-ee2fe87e2d/dist/'; // TODO: Add support for loading WASM files from cached buffer when we upgrade to onnxruntime-web@1.19.0 // https://github.com/microsoft/onnxruntime/pull/21534