Skip to content

Commit 62cce28

Browse files
build(ui): import elkjs directly
1 parent f7d021d commit 62cce28

File tree

3 files changed

+3
-32
lines changed

3 files changed

+3
-32
lines changed

invokeai/frontend/web/src/features/nodes/hooks/useAutoLayout.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useStore } from '@nanostores/react';
22
import type { NodeChange } from '@xyflow/react';
33
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
4-
import type { ELK as ELKType, ElkExtendedEdge, ElkNode } from 'elkjs';
5-
import * as ElkModule from 'elkjs/lib/elk.bundled.js';
4+
import type { ElkExtendedEdge, ElkNode } from 'elkjs/lib/elk.bundled.js';
5+
import ELK from 'elkjs/lib/elk.bundled.js';
66
import { $templates, nodesChanged } from 'features/nodes/store/nodesSlice';
77
import { selectEdges, selectNodes } from 'features/nodes/store/selectors';
88
import {
@@ -17,13 +17,7 @@ import type { AnyNode } from 'features/nodes/types/invocation';
1717
import { isInvocationNode } from 'features/nodes/types/invocation';
1818
import { useCallback } from 'react';
1919

20-
// This is a workaround for a common issue with how ELKjs is packaged. The bundled script doesn't have a
21-
// clean ES module export, so we import the module namespace and then extract the constructor, which may
22-
// be on the `default` property or be the module itself.
23-
const ElkConstructor = ((ElkModule as unknown as { default: unknown }).default ?? ElkModule) as new (
24-
options?: Record<string, unknown>
25-
) => ELKType;
26-
const elk: ELKType = new ElkConstructor();
20+
const elk = new ELK();
2721

2822
// These are estimates for node dimensions, used as a fallback when the node has not yet been rendered.
2923
const ESTIMATED_NODE_HEADER_HEIGHT = 40;

invokeai/frontend/web/src/types/elkjs.d.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

invokeai/frontend/web/vite.config.mts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ export default defineConfig(({ mode }) => {
7272
tsconfigPaths(),
7373
visualizer() as unknown as PluginOption,
7474
],
75-
optimizeDeps: {
76-
include: ['elkjs/lib/elk.bundled.js'],
77-
},
7875
build: {
7976
chunkSizeWarningLimit: 1500,
8077
},

0 commit comments

Comments
 (0)