-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Web] When the "node" condition path in exports is null vite (+svelte) build will wrongly throw a "No known conditions for" error #22361
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
Comments
I added this |
From: vitejs/vite#18015 (posted issue with vite initially--this was a mistake):
@hi-ogawa Couldn't reproduce using plain vite because I am using sveltekit on top of vite which builds the server side rendering part no matter what (see here: sveltejs/kit#2937). So even though I don't use the package in a node environment and have SSR disabled, it's still trying to build for node. This is a sveltekit issue so I will close this. Sorry to bother you unnecessarily. |
@fs-eire I wonder if this can be reopened and there to be a different solution to this problem? I have also run into this problem, and for SvelteKit there is simply no workaround at the moment or in the near future (as far as I can tell). Even when you disable server side rendering (SSR) in SvelteKit, all files are still analyzed (imports are done, this package fails) on the server during build time, for example to look for the I understand that this should not work on node, and that is a very valid stance, but maybe restricting it so that it's not even possible to import is a bit too strict? It would be very helpful if it was at least possible to import this on the server without getting the Eventually I hope that SvelteKit will allow for disabling of the SSR analyze/build step for client side only apps. but even then it might be a problem for hybrid apps? not sure. TL;DR: Would you be open to removing
This will make it possible to import e.g. the WebGPU version during static analysis on the server, but it would still prevent users from running e.g. WebGPU code on the server. Thanks, would love to hear your thoughts on this! |
Describe the issue
I am trying to build a project with this line. I've used webgl here but this applies to any import path (/wasm, /all, /webgpu, etc). Just importing "onnxruntime-web" without a path works though.
when I run vite build I get this error:
The issue is with the exports of this particular package.json (excerpt from original).
!!! Note that the node condition for webgl is null: !!!
Vite will error if
node:
's value isnull
. If I change it to any working path (e.g."/types.d.ts"
) then it won't blow up and will correctly resolve to"import": "./dist/ort.webgl.min.mjs",
. So this does work:Also swapping the order works also (no build error). Note that
"import": "./dist/ort.webgl.min.mjs",
is now before"node": null
:Further info
From here: https://nodejs.org/api/packages.html#package-entry-points, it can be seen that null should not be used like this.
System Info
To reproduce
Create a new vite project
npm create vite@latest
Add the package:
npm add -D onnxruntime-web
In index.ts:
import * as ort from "onnxruntime-web/webgl";
Then run the default build script from vite.
Urgency
I have a script that corrects this package.json so not urgent.
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.19.2
Execution Provider
'webgl' (WebGL), 'wasm'/'cpu' (WebAssembly CPU), 'xnnpack' (WebAssembly XNNPACK), 'webgpu' (WebGPU), Other / Unknown
The text was updated successfully, but these errors were encountered: