CodyC
CodyC
DDeno
Created by πŸŽ€π”Έβ„•π”Ύπ”Όπ•ƒ π”»π•†π•ƒπ•ƒπ”½π”Έβ„‚π”ΌπŸŽ€πŸ‡΅πŸ‡Έ on 6/17/2024 in #help
Trouble with serving HTMl on localhost
I'm working on a little project that does SSR myself. Would love to hear about your framework. Relatedly (shameless plug) I developed deno-embedder (https://jsr.io/@nfnitloop/deno-embedder) to make it easy to embed any static files necessary for SSR into the Deno binary so they all get bundled with deno install or deno compile. Might be useful for you?
10 replies
DDeno
Created by zettca on 6/21/2024 in #help
Deno JSR API package + CLI entrypoint "best-practices"
I have Opinions but, of course, everything depends on your use case(s).
1. Have the mod.ts entrypoint exports both the JS API and the CLI (under import.meta.main)
This is my preferred path, for ease-of-use for users. They gete a short package path, and deno install will likely install with a name that makes sense for your package. I assume by "under import.meta.main" you mean that you have a call to main() in your mod.ts that's guarded by an if (import.meta.main) {. πŸ‘ You may want to export your main() function too, so folks can execute it from a script, instead of having to execute it as a standalone process. Depends on your use case. (ex: that might be less useful if your CLI is very interactive.) If you're also exposing an API, that may be a better way for them to use it.
2. Have multiple entrypoints, but the imports won't be "pretty" (eg. jsr:@scope/myThing/cli.ts)
JSR exports can be prettier than that. You can have an export "cli" which maps to "cli.ts" internally. The downside here is that, I think if you deno install that, you're going to get a script called cli which isn't very user-friendly. 1 & 2 don't have to be exclusive. You can do both. Have a default (./) entrypoint which can act as main and exposes the API, and a separate /api export which only gives the API for those that want a smaller dependency graph.
3. Separate the CLI into a separate package
Yeah, this seems like overkill until your project gets quite large. Managing two(+) separate packages that are tightly coupled is a headache.
3 replies
DDeno
Created by martpet on 6/24/2024 in #help
Plain javascript in .js files in vscode
You may already know, but to tell deno to allow (and autocomplete) DOM types, you'll need to add "dom" to compilerOptions.lib in deno.json[c]. See: https://docs.deno.com/runtime/manual/advanced/typescript/configuration#using-the-lib-property Unfortunately, these compiler options seem to be project-wide, even if you specify them with triple-slash directives in individual files. The only way I've seen to have separate rules for separate files is to make them separate deno projects.
3 replies
DDeno
Created by Sheik on 6/24/2024 in #help
Problem with www.
I see they both resolve to the same IP addresses, so it looks like DNS is correct. βœ… I haven't used Deno Deploy, but services usually have a configuration that lists which domain name(s) that they should respond to with your content. You probably need to find that in Deno Deploy settings and add www. to the list.
2 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
anyway, This thread isn't to argue about that. My question is whether there's a way to get a file as a Blob in Deno (without just reading it into memory). Seems like there's not, so I'll write my own.
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
(also corroberated by the last link I shared.)
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
Having worked with Blobs in browsers, I can tell you that they're not in memory.
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
see this conversation for more details: https://github.com/denoland/deno/discussions/10539
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
It can be backed by in-memory data, but the API does not reqiure it.
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
Plus its API. You wouldn't need arrayBuffer() to return a Promise if it weren't potentially going to do I/O.
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
https://developer.mozilla.org/en-US/docs/Web/API/Blob
Blobs can represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
NBD, I'm writing a wrapper for it. Maybe I'll publish it to jsr when I'm satisfied with it.
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
The Blob API supports asynchronously reading slices of the underlying file with a very nice API: * any Blob can synchronously get a blob.slice() which itself is a Blob. * Only when reading the bytes is async required, to wait for the bytes from the underlying store.
20 replies
DDeno
Created by CodyC on 4/1/2024 in #help
How to open a file as blob?
Yep. I should've stated that I was looking for a solution that didn't require reading the entire file into memory, because that's trivially easy, and I'm looking to use the Blob API so that I don't have to hold the whole thing in memory. πŸ˜…
20 replies
DDeno
Created by CodyC on 3/24/2023 in #help
Help debugging command that doesn't exit.
There's an undocumented stop() method that you have to call to avoid this problem. 🀦 https://deno.land/x/esbuild@v0.17.12/mod.js?s=stop This doesn't seem to be documented in the official API docs: https://esbuild.github.io/api/
4 replies
DDeno
Created by CodyC on 3/24/2023 in #help
Help debugging command that doesn't exit.
Looks like esbuild isn't cleaning up after itself:
- 1 async operation to op_read was started in this test, but never completed. The operation was started here:
at handleOpCallTracing (ext:core/01_core.js:216:42)
at opAsync (ext:core/01_core.js:209:15)
at read (ext:deno_io/12_io.js:108:28)
at FsFile.read (ext:deno_fs/30_fs.js:609:12)
at readMoreStdout (https://deno.land/x/esbuild@v0.17.12/mod.js:1894:49)
at https://deno.land/x/esbuild@v0.17.12/mod.js:1899:11
- 1 async operation to op_read was started in this test, but never completed. The operation was started here:
at handleOpCallTracing (ext:core/01_core.js:216:42)
at opAsync (ext:core/01_core.js:209:15)
at read (ext:deno_io/12_io.js:108:28)
at FsFile.read (ext:deno_fs/30_fs.js:609:12)
at readMoreStdout (https://deno.land/x/esbuild@v0.17.12/mod.js:1894:49)
at https://deno.land/x/esbuild@v0.17.12/mod.js:1899:11
4 replies