Open designervoid opened 9 months ago
src/ton-connect-ui-build/index.js
:
src/ton-connect-ui-build/index.js
:
src/App.tsx
:
As a temporary solution, I'm using a bad practice patch, utilizing the built index.js
+ index.d.ts
from node_modules.
With this patch, the UI component doesn't break during HMR.
I added context to the SolidJS app, and developer experience improved. However, if I modify the files associated with @tonconnect/ui, the render is triggered again and the web component disappears in dev mode.
This same issue happens with Svelte/Vite both production and development builds. I believe any frontend system that is dynamically creating pages, which may include recreating #tc-root
element, might suffer from this, and some kind of workaround is needed.
In the context of
Vite
development, how might you ensureTonConnectUI
from@tonconnect/ui
doesn't interfere with HMR?For instance, let's consider an application with
@tonconnect/ui
+Solid.js
+Vite
. We have an updatedApp.tsx
after the commandpnpm create vite solidjs-vite-tonconnect2.0 --template solid-ts
:Then, we insert something into jsx and save - HMR doesn't trigger.
Let's consider the next scenario where we remove everything related to
tonconnect2.0
:Restart
Vite
withCtrl + C
and thenpnpm run dev
. This is needed because HMR isn't working. Normally, you'd only see the span update without thetonconnect2.0
logic. After restarting, you should see thespan
displaying 'hmr works 1'Insert:
Save.
And we see that the new span was inserted into jsx and rendered in the browser.
However, if we keep the logic related to
ton-connect2.0
, then#tc-root
won't re-render and we'll see errors in the browser console: