How to get dev env Hot Module Reload working?
What's the normal process for HMR?
I tried
yarn dev
but it opens in a browser window and I therefor can't login as gamemaster
because I'm already logged in to the main app on that account.
I created a second user also with gamemaster
privs and that then seems to enable HMR in the browser, but not in the Desktop App.
Is this behaviour correct and as expected or is there a way to make the desktop app respond to HMR?10 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
The Electron app is not going to point to the dev server automatically. It is going to go to the port that it is configured to which by default is
30000
.
The ideal recommended setup for development is to configure your IDE to open a debugger browser instance to http://localhost:30001
after starting the Foundry server and the Vite dev server. This is a lot easier and hassle free with WebStorm to setup. To stop the Vite dev server from automatically opening a browser set server.open
to false
in the Vite config. Refer the Vite config documentation for more information.I launch foundry through node using command prompt and then do everything on Edge
I've also noticed that dynamic imports don't work on the electron app. Does that mean that my system will not work in the electron app if someone installs it?
E.g. this component:
That works in the browser via dev server. However in electron it yields:
I suppose this can be chalked up to a misunderstanding of what Svelte is... Svelte is a compile time library. You can't load / import a
.svelte
file dynamically at runtime. That this works w/ the dev server is a curious side effect.
If you have various Svelte components that you want to load from a prop, chatTemplate
, you need to create a way to connect that reference to compiled components. You could export a Map or object from a JS file that organizes compiled components that are handled at build time.
Pseudo-code ahead (JS file):
In Svelte component that handles displaying a chat message:
I'm sure this can be improved for better error checking... Just pseudo-code I typed out.So much for my clever-bollocks way of avoiding typing out all the imports!
I create index.js files in directories that contains a lot of Svelte components like this:
index.js in some folder
In your case you could do this (again all pseudo-code, but should work):
This is mostly fundamental ES Modules related import / export handling and a good reason to buff up on how ESM works in general.What a mission but thank you for that, it works!
The componentMap idea worked for me. The latter idea errored with
Could be
import * as ChatComponents from '../whereever/chat/components/are/';
Again pseudo-code above...I was just missing the index.js for that 🤦🏻♂️