Mango Juicy
Mango Juicy
Explore posts from servers
SSolidJS
Created by RaySlash on 10/14/2024 in #support
Deploying a VITE+Solid app
The docker and docker-compose setup probably adds unnecessary complexity. Where are you deploying to? With SPA's usually this is deployed to some object storage like S3 which would have higher uptime and is probably cheaper than a running a server
8 replies
SSolidJS
Created by RaySlash on 10/14/2024 in #support
Deploying a VITE+Solid app
For super easy deployment, you can use something like Cloudflare pages, Vercel, Netlify. Then you don't need to create a docker image.
8 replies
SSolidJS
Created by AlexErrant on 10/12/2024 in #support
How to mount a Solid component to a dom element?
There's a non-compiled version of Solid that can be direcly used in vanilla js, but the experience would't be great: https://www.solidjs.com/guides/getting-started#buildless-options Could work if all other options fail
11 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
Unfortunately this is quite verbose. The ideal solution would probably be some sort of Vinxi plugin with Workbox solution
19 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
As for busting previous cache versions in sw.js
// Update and bust old caches
self.addEventListener('activate', (event) => {
const currentCaches = [PRECACHE_VERSION, RUNCACHE_VERSION]
event.waitUntil(
caches
.keys()
.then((cacheNames) => {
return cacheNames.filter((cacheName) => !currentCaches.includes(cacheName))
})
.then((cachesToDelete) => {
return Promise.all(
cachesToDelete.map((cacheToDelete) => {
return caches.delete(cacheToDelete)
}),
)
})
.then(() => self.clients.claim()),
)
})
// Update and bust old caches
self.addEventListener('activate', (event) => {
const currentCaches = [PRECACHE_VERSION, RUNCACHE_VERSION]
event.waitUntil(
caches
.keys()
.then((cacheNames) => {
return cacheNames.filter((cacheName) => !currentCaches.includes(cacheName))
})
.then((cachesToDelete) => {
return Promise.all(
cachesToDelete.map((cacheToDelete) => {
return caches.delete(cacheToDelete)
}),
)
})
.then(() => self.clients.claim()),
)
})
19 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
The service worker can be loaded in entry-client.tsx
import { StartClient, mount } from '@solidjs/start/client'

if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js', { scope: '/' }).then(
(registration) => {
console.log('Service worker registration succeeded:', registration)
},
(error) => {
console.error(`Service worker registration failed: ${error}`)
},
)
} else {
console.error('Service workers are not supported.')
}

mount(() => <StartClient />, document.getElementById('app')!)
import { StartClient, mount } from '@solidjs/start/client'

if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js', { scope: '/' }).then(
(registration) => {
console.log('Service worker registration succeeded:', registration)
},
(error) => {
console.error(`Service worker registration failed: ${error}`)
},
)
} else {
console.error('Service workers are not supported.')
}

mount(() => <StartClient />, document.getElementById('app')!)
19 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
As a basic solution this is what I have in the sw.js file in public
const monthMillis = 1000 * 60 * 60 * 24 * 30

// Precache large files - 1 Month
const PRECACHE_VERSION = `precache-v${Math.floor(Date.now() / monthMillis)}`
const PRECACHE_URLS = [
'/fluidsynth/fluidsynth.js',
'/fluidsynth/synth.min.js',
'/fluidsynth/synth.worklet.min.js',
'/piano.sf3',
]
self.addEventListener('install', (event) => {
event.waitUntil(
caches
.open(PRECACHE_VERSION)
.then((cache) => cache.addAll(PRECACHE_URLS))
.then(self.skipWaiting()),
)
})
const monthMillis = 1000 * 60 * 60 * 24 * 30

// Precache large files - 1 Month
const PRECACHE_VERSION = `precache-v${Math.floor(Date.now() / monthMillis)}`
const PRECACHE_URLS = [
'/fluidsynth/fluidsynth.js',
'/fluidsynth/synth.min.js',
'/fluidsynth/synth.worklet.min.js',
'/piano.sf3',
]
self.addEventListener('install', (event) => {
event.waitUntil(
caches
.open(PRECACHE_VERSION)
.then((cache) => cache.addAll(PRECACHE_URLS))
.then(self.skipWaiting()),
)
})
19 replies
SSolidJS
Created by Mango Juicy on 8/15/2024 in #support
What is the timeout of 'use server' functions?
Ideally, I should probably use server sent events, but is that possible in Solid Start?
9 replies
SSolidJS
Created by Mango Juicy on 8/15/2024 in #support
What is the timeout of 'use server' functions?
While avoiding the increased load on database of short polling
9 replies
SSolidJS
Created by Mango Juicy on 8/15/2024 in #support
What is the timeout of 'use server' functions?
Think of it as a scrappy way of avoiding the complexity of websocket
9 replies
SSolidJS
Created by Mango Juicy on 8/15/2024 in #support
What is the timeout of 'use server' functions?
No description
9 replies
SSolidJS
Created by Mango Juicy on 8/15/2024 in #support
What is the timeout of 'use server' functions?
Not quite what I was asking. I intend to keep a connection open extended time like 30 - 60 seconds for a long running POST request - in this case a use server function Short polls are strait forward. But what happens if the server function is hanging for longer polls? Or is this generally bad practice?
9 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
Honestly I think it makes more sense to only use one framework
19 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
I ran into that problem once with an astro and solid js app
19 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
Yeah, otherwise the precaching doesn't work properly?
19 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
Fascinating. I guess worst case scenario, I'll have to write it directly into html or separate ts file
19 replies
SSolidJS
Created by Mango Juicy on 8/2/2024 in #support
createAsync different values on client and server SSR issue
I found a GitHub issue detailing the children hydration mismatch: https://github.com/solidjs/solid-start/issues/1392
16 replies
SSolidJS
Created by Mango Juicy on 8/2/2024 in #support
createAsync different values on client and server SSR issue
Yeah, I think that was the cause. How did this solve the problem?
16 replies
SSolidJS
Created by Mango Juicy on 8/2/2024 in #support
createAsync different values on client and server SSR issue
const dc = children(() => props.dialogChildren)
const c = children(() => props.children)
const dc = children(() => props.dialogChildren)
const c = children(() => props.children)
16 replies
SSolidJS
Created by Mango Juicy on 8/2/2024 in #support
createAsync different values on client and server SSR issue
They are both child components
16 replies