-
Notifications
You must be signed in to change notification settings - Fork 299
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
[Bug] vite + vue3 + worker + wasm #1238
Comments
You are so lucky that I just fixed this and by accident I'm here seeing this issue, use import { wasm } from "@rollup/plugin-wasm";
return {
worker: {
plugins: () => [wasm({ sync: ["ICRPolySeg.wasm"] })],
},
plugins: [wasm({ sync: ["ICRPolySeg.wasm"] })]
}; Edit: The api of workers might be different according to your vite version(4 or 5) |
@shunia Hi, thanks for your reply. I can make my project built with your guidance, but there is something error when I create and initialize ICRPolySeg object. The ICRPolySeg object cannot be initialized. |
Hello, the OP is my colleague. |
When I use labelmap to convert to contour, the file under woker will become like this |
Since there are many other people complaining about web workers and Vite as well, I'm adding this here. |
I'm working on cornerstone3D 2.x and have made progress in removing circular dependencies and publishing the types for the DICOM image loader. I'm trying to make it work with Vite, but there are numerous issues with Vite in https://github.com/vitejs/vite/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+import.meta.url I have started a template project for Vite, React, and cornerstone3D beta 2.x here. I appreciate your help in making it work. |
@sedghi Hi, I have tried a ugly method to resolve this problem since Vite does not support import wasm through import.meta.url. I uploaded a demo here https://github.com/Qwd2017/icrdemo. |
@Qwd2017 I can't see the config, https://github.com/Qwd2017/icrdemo/blob/main/icrdemo/vite.config.ts Can you make sure the code is pushed? |
The file contents are as follows. import { defineConfig } from "vite"; function resolve(dir: string) { // https://vitejs.dev/config/ |
Are there breaking changes in APIs using cornerstone3D 2.0? So, is it easy to update from v1? @sedghi I already made a nice scaffolding for VUE3+Vite5+Vuetify3+Pinia+CornerStone3D, all last versions, similar to |
There is a workaround posted in the cornerstone Slack channel by Adrien that works for production:
This worked for me in
|
You can now safely use Cornerstone3D with WebAssembly and everything in Cornerstone3D 2.0. See here. |
Describe the Bug
I want to convert labelmap segmentation to contour, but there is something wrong with @iCr\polyseg-wasm.
Steps to Reproduce
1.create a project with vite+vue3
2.install cornerstone3D to project
3.copy and modify demo source code(https://www.cornerstonejs.org/live-examples/polysegwasmvolumelabelmaptocontour) to project
4.run build
vite configuration is as follows:
import vue from "@vitejs/plugin-vue";
import wasm from "vite-plugin-wasm";
return {
plugins: [
vue(),
wasm(),
],
worker: {
plugins: [wasm()],
},
};
The current behavior
throw new Error(
[vite]: Rollup failed to resolve import "${exporter}" from "${id}".\n
+^
Error: [vite]: Rollup failed to resolve import "a" from "xxx/node_modules/@icr/polyseg-wasm/dist/ICRPolySeg.wasm".
code: 'PLUGIN_ERROR',
plugin: 'commonjs--resolver',
hook: 'resolveId',
id: 'xxx/node_modules/@cornerstonejs/tools/dist/esm/stateManagement/segmentation/polySeg/registerPolySegWorker.js'
The expected behavior
The project can be successfully built.
OS
win10 20H2
Node version
v18.16.0
Browser
Chrome 124.0.6367.119
The text was updated successfully, but these errors were encountered: