jeff.hykin
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
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:
Will print
"Hello world"
then
"1"
Because static imports get hoisted to the top
12 replies
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
Binaryify (as of today) will auto-update the "./your.dylib.binaryified.js"
file every time time the "./your.dylib"
file changes3 replies
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
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
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
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
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