Skip to content

Commit a61214c

Browse files
committed
refactor(cli): use esbuild aliases for WASM builds
Add esbuild alias for onnxruntime-web and remove yoga-layout patch. Changes: - Add onnxruntime-web@1.23.0 as devDependency - Add esbuild alias redirecting onnxruntime-web to build/onnx-sync.mjs - Restore type import from onnxruntime-web in minilm-inference.mts - Remove yoga-layout patch (no longer needed with esbuild alias) Both yoga-layout and onnxruntime-web now follow the same pattern: 1. npm package installed as devDependency (for types and dependencies like ink) 2. esbuild plugin redirects imports to custom synchronous WASM builds 3. Custom builds from packages/yoga-layout and packages/onnxruntime
1 parent 8a5870f commit a61214c

File tree

4 files changed

+127
-3
lines changed

4 files changed

+127
-3
lines changed

packages/cli/.config/esbuild.cli.build.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,18 @@ const config = {
355355
},
356356
},
357357

358+
{
359+
name: 'onnx-wasm-alias',
360+
setup(build) {
361+
// Redirect onnxruntime-web to our custom synchronous implementation.
362+
build.onResolve({ filter: /^onnxruntime-web$/ }, () => {
363+
return {
364+
path: path.join(rootPath, 'build/onnx-sync.mjs'),
365+
}
366+
})
367+
},
368+
},
369+
358370
{
359371
name: 'stub-problematic-packages',
360372
setup(build) {

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"@socketsecurity/build-infra": "workspace:*",
9191
"del": "8.0.1",
9292
"ink-text-input": "6.0.0",
93+
"onnxruntime-web": "1.23.0",
9394
"rollup": "4.50.1",
9495
"rollup-plugin-visualizer": "6.0.5",
9596
"tar-stream": "3.1.7",
@@ -164,8 +165,7 @@
164165
"graceful-fs@4.2.11": "patches/graceful-fs@4.2.11.patch",
165166
"lodash@4.17.21": "patches/lodash@4.17.21.patch",
166167
"string_decoder@0.10.31": "patches/string_decoder@0.10.31.patch",
167-
"ink@6.3.1": "patches/ink@6.3.1.patch",
168-
"yoga-layout": "patches/yoga-layout.patch"
168+
"ink@6.3.1": "patches/ink@6.3.1.patch"
169169
}
170170
},
171171
"typeCoverage": {

packages/cli/src/utils/minilm-inference.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
import { WordPieceTokenizer } from './wordpiece-tokenizer.mts'
5252

5353
import type { Vocabulary } from './wordpiece-tokenizer.mts'
54-
import type { InferenceSession } from '../../build/onnx-sync.mjs'
54+
import type { InferenceSession } from 'onnxruntime-web'
5555

5656
/**
5757
* MiniLM inference result.

pnpm-lock.yaml

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)