jeff.hykin
jeff.hykin
DDeno
Created by jradxl on 9/30/2024 in #help
Deno import use for local files?
I use deno as a replacement to bash (checkout dax, it is fantastic for that) I'm confused, why did dynamic imports not work for you? That seems like way way less work than creating a server
10 replies
DDeno
Created by RedBean on 9/30/2024 in #help
Is deno's cache philosophy coherent for local files ?
You might want to add something like this at the top:
const load = (path)=>import(
path+(
Deno.env.get("PROD") ? "" : `${Math.random()}`
)
)
const load = (path)=>import(
path+(
Deno.env.get("PROD") ? "" : `${Math.random()}`
)
)
Then use that instead of imports:
// var is the only one that let's the cell run twice without error
var utils = load("./utils.ts")
// var is the only one that let's the cell run twice without error
var utils = load("./utils.ts")
12 replies
DDeno
Created by RedBean on 9/30/2024 in #help
Is deno's cache philosophy coherent for local files ?
Ah, for TS that is true, that's my bad for assuming the local import was JavaScript. Should still 100% be a bug across restarts though. I agree its annoying in Jupyter. To be fair though, python reimports also don't work in Jupyter. I mean python has some force-reload stuff but its about the same amount of work as force reloading in deno, and is equally not-good-for-prod.
12 replies
DDeno
Created by RedBean on 9/30/2024 in #help
Is deno's cache philosophy coherent for local files ?
It definitely shoudnt persist across restarts though. That would 100% be a bug for local-file-path imports. The "cache" is only in ram.
12 replies
DDeno
Created by RedBean on 9/30/2024 in #help
Is deno's cache philosophy coherent for local files ?
(I'm not part of the deno team btw) AFAIK NodeJS does this as well when ES imports are enabled. Its not a deno behavior, its an ES import vs common js behavior. It is annoying in the repl and juypter. Another painful edgecase (for files not repl) is execution order:
console.log("1")
import "hello_world.js"
console.log("1")
import "hello_world.js"
Will print "Hello world" then "1" Because static imports get hoisted to the top
12 replies
DDeno
Created by raaymax on 9/29/2024 in #help
How to workaround `deno compile` binary file limitations?
Well theres one hacky workaround. I made a tool last year https://deno.land/x/binaryify that lets us ES import .dylib files as a Uint8Array. We can then write that array to a temp file at runtime and then dlopen that file. It would look like: 1. Install binaryify 2. Run binaryify -- ./your.dylib 3. Instead of calling .dlopen do
import dylibBytes from "./your.dylib.binaryified.js"

let tempFile = await Deno.makeTempFile()
await Deno.writeFile(tempFile, dylibBytes)

Deno.dlopen(file)
import dylibBytes from "./your.dylib.binaryified.js"

let tempFile = await Deno.makeTempFile()
await Deno.writeFile(tempFile, dylibBytes)

Deno.dlopen(file)
Binaryify (as of today) will auto-update the "./your.dylib.binaryified.js" file every time time the "./your.dylib" file changes
3 replies
DDeno
Created by Meep on 9/27/2024 in #help
JXS/TSX Transformation from within browser code?
I'm decently-highly confident the answer is no, not without some hacks like writing to a file or calling a child process. Theres also a decent number of ways to create a security vulnerability on the backend with user generated code. So I think babel in the frontend is your best bet
4 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
That looks theyre doing a isFile && !isFifo check under the hood to me
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
Ah, here's the check. Only works on MacOS/Linux https://docs.deno.com/api/deno/~/Deno.FileInfo.isFifo
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
Like they've got a full path, something like /var/p/$pid/1 or /dev/something/$pid/1 and deno .isFile() returns true for those paths There's files that are fifo streams and I think deno has a check somewhere for that since those can exist as a local file too (like $HOME/my_fifo)
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
At least on Linux and macos those are still files on disk
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
I am interested to know, what is the pipe if not a file?
20 replies
DDeno
Created by m4rc3l05 on 9/21/2024 in #help
How to check if stdin is a file?
I was going to mention Deno.isatty but its also deprecated and there's nothing about it on the migration page. I'm pretty sure I saw the new tty interface somewhere (it might be on the file class now)
20 replies
DDeno
Created by Moomoo on 9/18/2024 in #help
Child process doesn't exit on .kill()
Thats rough, but hey if it works it works
8 replies
DDeno
Created by Moomoo on 9/18/2024 in #help
Child process doesn't exit on .kill()
Probably need to do .kill("SIGKILL") since I believe by default it only sends SIGSTOP But thats for Linux/Mac so idk if there's a windows specific issue going on here
8 replies
DDeno
Created by Mqx on 8/27/2024 in #help
Binary files in jsr package
Yeah theres only so much that can be done while waiting on JS to support importing binary data
11 replies
DDeno
Created by Mqx on 8/27/2024 in #help
Binary files in jsr package
In terms of deployment/CI Its still clunky to use, so if you have any suggestions let me know. It would probably be nice to have a "watch" feature where the binarifyied version of a file is auto generated
11 replies
DDeno
Created by Mqx on 8/27/2024 in #help
Binary files in jsr package
It works for non-binary files too. A good example is: I wanted to compile a small web UI into single executable - problem: normally would use Deno.readTextFile("index.html") but then that means the html file needs to get shipped along with the executable. - solution: - use normal web bundler code to generate one HTML file - binaryify that HTML file - import instead of readTextFile - run deno compile - result: one self-contained executable
11 replies
DDeno
Created by Mqx on 8/27/2024 in #help
Binary files in jsr package
Sorry for the late reply, but yep that's exactly what it does
11 replies
DDeno
Created by Mqx on 8/27/2024 in #help
Binary files in jsr package
Idk about jsr, but if you want it to work with bundlers (and JSR) I made this tool a couple years ago for binary files. It let's you import anything as a Uint8Array. I used it to make deno-tree-sitter and also use it in a couple other of my deno modules https://github.com/jeff-hykin/binaryify/
11 replies