T
TyphonJS15mo ago
Solidor

System Works in Dev Mode but not after build

After updating to 0.1.1, I noticed something odd happening. The TITAN system now seems to work when I run in dev mode. But when I run a built version, there is nothing. It's just the base foundry system. Some debugging shows me that the init hook is not getting called, and I have no idea why. Any idea what could cause this?
12 Replies
Solidor
Solidor15mo ago
Init hook is in the built file so I dunno why its not working... Reverting to my old vite file apparently fixed it. Not sure why. I'll upload the working and non working versions
Solidor
Solidor15mo ago
Working version
Solidor
Solidor15mo ago
Non working version
Solidor
Solidor15mo ago
Through process of elimination I was able to narrow it down to this. In the second, non-working vite config, the following has been removed.
define: {
'process.env': {}
},
define: {
'process.env': {}
},
This seems to be what causes the built version of the system to not work. If I add it back in, everything works again. Feel like this is worth mentioning, because the vite config is based off the one in the essential svelte esm. https://github.com/typhonjs-fvtt-demo/template-svelte-esm/blob/main/vite.config.mjs
GitHub
template-svelte-esm/vite.config.mjs at main · typhonjs-fvtt-demo/te...
Provides a basic Foundry module template w/ TRL and ES modules to generate your own module. - typhonjs-fvtt-demo/template-svelte-esm
TyphonJS (Michael)
Let me know if you have a resolution to this. There should be no need for the process.env code block above as that would be Node related.
Solidor
Solidor15mo ago
So far my only resolution seems to be to add the process.env back in, but I will investigate and see if I can find something else that could cause this.
TyphonJS (Michael)
The only thing I can think of is Vite version and Svelte version and something else external to TRL that causes an issue or is a temporary bug w/ the given external dependency as that is not required in building TRL apps. Is this issue only w/ the dev server? process.env is a Node concern, etc. Are there any error messages?
Solidor
Solidor15mo ago
No error message. The dev server works fine. Its the built version that never runs the init hook without it.
TyphonJS (Michael)
Are you including other Node modules in your build?
Solidor
Solidor8mo ago
Just in case this trips up anyone else... I am starting a major rewrite / update of the titan system, and I found out why this was breaking. It was the tippy package. It requires you to define process.env. It was working fine in dev mode. But in production mode, it was causing the build to fail. https://atomiks.github.io/tippyjs/v6/faq/#im-getting-uncaught-referenceerror-process-is-not-defined
FAQ
The complete tooltip, popover, dropdown, and menu solution for the web
TyphonJS (Michael)
Right on.. Yeah. I figured it was something external being bundled. Just a heads up. TRL 0.2.0 will have some minor breaking changes; nothing crazy like Foundry though. Basically callbacks will take an object now instead of separate arguments. I'll fully describe things on release. You'll just have to put {} around arguments in callbacks.
Want results from more Discord servers?
Add your server