fix: initialize DICOM decoder modules in browser workers
This commit is contained in:
1 parent
dd29258828
commit
7a1d18dfc6
8 files changed
+105
-41
No files matched your search
@@ -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");
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user