Skip to content

Instantly share code, notes, and snippets.

@schickling
Created October 21, 2025 09:56
Show Gist options
  • Save schickling/aaee7f6e952351f4b0f79c2af3e56a5f to your computer and use it in GitHub Desktop.
Save schickling/aaee7f6e952351f4b0f79c2af3e56a5f to your computer and use it in GitHub Desktop.

Revisions

  1. schickling created this gist Oct 21, 2025.
    42 changes: 42 additions & 0 deletions vite-optimize-deps-module-graph.mmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    graph TD
    subgraph Single_JS_Runtime
    direction TB

    subgraph Devtools_Import_Graph
    A0[devtools entry]
    A1[@livestore/common<br/>(resolved path A)]
    A2[@livestore/utils<br/>(resolved path A)]
    A0 --> A1
    A0 --> A2
    A1 -->|define| A3[LSD.ClientSession.Pong class<br/>(instance α)]
    end

    subgraph App_Import_Graph
    B0[app entry]
    B1[@livestore/livestore]
    B2[@livestore/common<br/>(resolved path B)]
    B0 --> B1
    B1 -->|depends| B2
    B2 -->|define| B3[LSD.ClientSession.Pong class<br/>(instance β)]
    end
    end

    C0[Vite optimizeDeps configuration]

    %% Failure path: optimizeDeps excludes the app graph
    C0 -. excludes .-> B1
    C0 -. excludes .-> B2
    C0 -->|prebundle only devtools graph| A0

    A3 -- Schema.is(Pong) -->|expects class α| D1[Expect heartbeat]
    B3 -- instantiates -->|class β| D0[Heartbeat payload]
    D0 -- α ≠ β -->|Schema guard fails| E0[Disconnect]

    %% Success path: dedupe/shared module instance
    C1[Include/Alias shared modules]
    C1 --> A1
    C1 --> B2
    B2 -- resolve to A1 --> B2A[@livestore/common shared instance]
    A1 --> B2A
    B2A --> D0
    D0 -->|class α reused| D1
    1 change: 1 addition & 0 deletions vite-optimize-deps-module-graph.svg
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.