1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
From 2804004525c65df99cd8a563cfd316e796618ebd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tarek=20Ziad=C3=A9?= <tarek@ziade.org>
Date: Wed, 10 Apr 2024 10:06:19 +0200
Subject: [PATCH 1/1] patched
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Tarek Ziadé <tarek@ziade.org>
---
package.json | 2 +-
src/backends/onnx.js | 8 ++++++--
tsconfig.json | 13 +++++++++++++
webpack.config.js | 4 ++++
4 files changed, 24 insertions(+), 3 deletions(-)
create mode 100644 tsconfig.json
diff --git a/package.json b/package.json
index 446fd5f..24825d6 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
"types": "./types/transformers.d.ts",
"type": "module",
"scripts": {
- "typegen": "tsc ./src/transformers.js --allowJs --declaration --emitDeclarationOnly --declarationMap --outDir types",
+ "typegen": "tsc",
"dev": "webpack serve --no-client-overlay",
"build": "webpack && npm run typegen",
"generate-tests": "python -m tests.generate_tests",
diff --git a/src/backends/onnx.js b/src/backends/onnx.js
index 0bee3dc..030eff7 100644
--- a/src/backends/onnx.js
+++ b/src/backends/onnx.js
@@ -18,8 +18,12 @@
// NOTE: Import order matters here. We need to import `onnxruntime-node` before `onnxruntime-web`.
// In either case, we select the default export if it exists, otherwise we use the named export.
-import * as ONNX_NODE from 'onnxruntime-node';
-import * as ONNX_WEB from 'onnxruntime-web';
+//import * as ONNX_NODE from 'onnxruntime-node';
+//import * as ONNX_WEB from 'onnxruntime-web';
+
+import 'onnxruntime-web';
+const ONNX_WEB = ort;
+
/** @type {import('onnxruntime-web')} The ONNX runtime module. */
export let ONNX;
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..8892b18
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "files": [
+ "./src/transformers.js"
+ ],
+ "compilerOptions": {
+ "allowJs": true,
+ "declaration": true,
+ "emitDeclarationOnly": true,
+ "declarationMap": true,
+ "outDir": "types",
+ "types": [] // Or specify only the types you need
+ }
+}
diff --git a/webpack.config.js b/webpack.config.js
index c958b45..8b6b98b 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -51,4 +51,8 @@ export default {
experiments: {
outputModule: true,
},
+ externals: {
+ 'onnxruntime-node': 'NOT_USED',
+ 'onnxruntime-web': 'chrome://global/content/ml/ort-dev.js',
+ },
};
--
2.43.0
|