Skip to content

Commit ace0183

Browse files
committed
fix bundler issues
1 parent 78e1eb0 commit ace0183

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

packages/tools/src/tools/segmentation/strategies/utils/getItkImage.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
const peerImport = (moduleId) => {
22
if (moduleId === 'itk-wasm') {
3-
return import(/* webpackChunkName: "itk-wasm" */ 'itk-wasm');
3+
// NOTE: Assigning to a variable is necessary here to prevent bundlers
4+
// from chasing the import and statically including it. This avoids many hacks
5+
// related to declaring the import as external in Vite, etc.
6+
const moduleName = 'itk-wasm';
7+
return import(
8+
/* webpackChunkName: "itk-wasm" */
9+
moduleName
10+
);
411
}
512
};
613

packages/tools/src/workers/computeWorker.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@ import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
66

77
export async function peerImport(moduleId) {
88
if (moduleId === 'itk-wasm') {
9-
return import(/* webpackChunkName: "itk-wasm" */ 'itk-wasm');
9+
// NOTE: Assigning to a variable is necessary here to prevent bundlers
10+
// from chasing the import and statically including it. This avoids many hacks
11+
// related to declaring the import as external in Vite, etc.
12+
const moduleName = 'itk-wasm';
13+
return import(
14+
/* webpackChunkName: "itk-wasm" */
15+
moduleName
16+
);
1017
}
1118

1219
if (moduleId === '@itk-wasm/morphological-contour-interpolation') {
20+
// NOTE: Assigning to a variable is necessary here to prevent bundlers
21+
// from chasing the import and statically including it. This avoids many hacks
22+
// related to declaring the import as external in Vite, etc.
23+
const moduleName = '@itk-wasm/morphological-contour-interpolation';
1324
return import(
14-
/* webpackChunkName: "itk-wasm-morphological-contour-interpolation" */ '@itk-wasm/morphological-contour-interpolation'
25+
/* webpackChunkName: "itk-wasm-morphological-contour-interpolation" */
26+
moduleName
1527
);
1628
}
1729
}

packages/tools/src/workers/polySegConverters.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ import { checkStandardBasis, rotatePoints } from '../geometricSurfaceUtils';
1818

1919
export async function peerImport(moduleId) {
2020
if (moduleId === '@icr/polyseg-wasm') {
21+
// NOTE: Assigning to a variable is necessary here to prevent bundlers
22+
// from chasing the import and statically including it. This avoids many hacks
23+
// related to declaring the import as external in Vite, etc.
24+
const moduleName = '@icr/polyseg-wasm';
2125
return import(
22-
/* webpackChunkName: "icr-polyseg-wasm" */ '@icr/polyseg-wasm'
26+
/* webpackChunkName: "icr-polyseg-wasm" */
27+
/* @vite-ignore */
28+
moduleName
2329
);
2430
}
2531
}

0 commit comments

Comments
 (0)