Mango Juicy
Mango Juicy
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Mango Juicy on 10/29/2024 in #questions
Recommended abstract syntax tree for JavaScript/TypeScript
For context, I'm trying to create a Eslint plugin to detect JavaScript runtime compatibility issues. So I need to keep track of variable types - a bit like how TypeScript keeps track of types. I find the way Eslint exposes the AST to be quite limiting.
4 replies
SSolidJS
Created by Mango Juicy on 10/14/2024 in #support
Cloudflare worker presigned url S3, R2
How do you generate presigned urls or S3 or R2... from cloudflare workers? Solution: Use aws4fetch package which is designed to work on cloudflare workers: https://developers.cloudflare.com/r2/examples/aws/aws4fetch/ Do not use @aws-sdk/s3-request-presigner as this depends on a @smithy package that requires node:fs, which is unsupported on Cloudflare. Calling a node:fs will result in a is not a function error PS: I've already found a solution. Though I'd put this here for anybody facing the same issue.
1 replies
SSolidJS
Created by Mango Juicy on 9/29/2024 in #support
Client side singleton for heavy resource allocation
Is there a way to create a global singleton for client side without initialising again on page loads? In my case, I'm preloading a synthesizer on the web, which takes time to load. Disabling SSR and using only client side routing for subroutes could work. But how would you do that?
2 replies
SSolidJS
Created by Mango Juicy on 8/15/2024 in #support
What is the timeout of 'use server' functions?
Context: I plan to use long polling in an app I couldn't find any documentation on how to control timeouts for server functions. How should this be handled?
9 replies
SSolidJS
Created by Mango Juicy on 8/6/2024 in #support
Precache service worker
Is there any way to implement service worker for content precaching? For context I'm creating a website with a midi player. It would be great to precache large (1 to 21 MB ish) SoundFont files. I've tried using VitePWA plugin in Vinxi. It doesn't appear to register any service workers though. app.config.ts:
import { defineConfig } from '@solidjs/start/config'
import { VitePWA } from 'vite-plugin-pwa'

export default defineConfig({
vite: {
...
plugins: [
VitePWA({
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{ico,png,svg,jpg,webp,sf3,wasm}'],
},
}),
],
},
...
})
import { defineConfig } from '@solidjs/start/config'
import { VitePWA } from 'vite-plugin-pwa'

export default defineConfig({
vite: {
...
plugins: [
VitePWA({
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{ico,png,svg,jpg,webp,sf3,wasm}'],
},
}),
],
},
...
})
19 replies
SSolidJS
Created by Mango Juicy on 8/2/2024 in #support
createAsync different values on client and server SSR issue
I'm trying to conditionally render components based on auth - think paywalled content. I have a server function that detects if user has logged in:
const _userLoggedIn = cache(async () => {
'use server'
const sessionData = await getSession()
const userId = sessionData.data.userId
if (userId) return true
return false
}, 'userLoggedIn')
const _userLoggedIn = cache(async () => {
'use server'
const sessionData = await getSession()
const userId = sessionData.data.userId
if (userId) return true
return false
}, 'userLoggedIn')
However, createAsync returns undefined leading nothing to be rendered on the server:
const userLoggedIn = createAsync(() => _userLoggedIn(), { deferStream: true })
console.log(userLoggedIn())
const userLoggedIn = createAsync(() => _userLoggedIn(), { deferStream: true })
console.log(userLoggedIn())
Server:
undefined
undefined
Client returns the expected value:
true
true
16 replies
TTCTheo's Typesafe Cult
Created by Mango Juicy on 7/12/2024 in #questions
NPM library best practices?
I was creating my own NPM library, @menglinmaker/soundfont3 but there are so many technical decisions: - So many bundlers to choose from: esbuild, webpack, rollup, snowpack, tsup... - Do I bundle to 1 file? Tree-shake? - So many testing frameworks too: jest, vitest... - So many eslint plugins. - How do I even test if ESM and CJS imported correctly? Attempt: I decided to take inspiration from a few GitHub repos like vuejs/core, solidjs/solid, mrdoob/three.js. This is what I pickup up on: - Use script "preinstall" to force the use of "pnpm" for development. Very opinionated decision, but improves consistency with setup and CI. - Use script "postinstall" to ensure git hooks are installed. - Lint and format at least every pre-commit. - Use "eslint-plugin-compat" to detect browser compatibility issues for web apis. Areas for improvement in JS ecosystem: - Lack of runtime compatibility linting - does api exist on Node, Deno, Bun, Cloudflare worker...? TLDR: Mostly unsure what bundler + config and testing library to use. Eg: Apparently it's possible to unit test on a browser? Boilerplate repo: https://github.com/MengLinMaker/npm-library-boilerplate
11 replies