Skip to content

Commit

Permalink
Finalize module/commonjs build
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Aug 8, 2024
1 parent c04d37e commit d32fe2b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
13 changes: 6 additions & 7 deletions examples/segment-anything-client/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ export default defineConfig(env => {
}
};

// TODO: Add the following when using [email protected]
// 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;
});
15 changes: 10 additions & 5 deletions package-lock.json

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

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/backends/onnx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]
// https://github.com/microsoft/onnxruntime/pull/21534
Expand Down

0 comments on commit d32fe2b

Please sign in to comment.