fix: initialize DICOM decoder modules in browser workers

This commit is contained in:
SantaSpeen committed 2026-10-22 01:34:55 +03:00
1 parent dd29258828
commit 7a1d18dfc6
8 files changed
+105 -41

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
import type { Plugin } from "vite";
export function daikonCommonJS(): Plugin {
return {
name: "daikon-commonjs",
enforce: "pre",
transform(code, id) {
if (!/\/daikon\/(src|lib)\/.*\.js$/.test(id.replaceAll("\\", "/")))
return;
// Daikon guards static CommonJS imports with a runtime require check.
// Bundlers replace the calls, but leave the check false in browsers.
return code.replace(/typeof require\s*!==\s*['"]undefined['"]/g, "true");
},
};
}