#`require()` equivalent
17 messages · Page 1 of 1 (latest)
import myData from "./some-data.json" assert { type: "json" };
You won't need the assertion for js, JSX, etc tho
Thanks, it works indeed.
BTW, is there a list of the types that I can import somewhere?
For example, can I import a yaml file? It looks like I cannot.
you can import js, ts, jsx, tsx files. You can import json with the assertion
and with node compatibility, you can import vue, svelte, etc
for yaml, you can just use Deno.readFileSync and then parse the text content
I use Deno as a JS bundler, so I wanted the file to be bundled with the remaining, but maybe Deno isn't the appropriate tool for that. I'm not used to write a full website, and I'm afraid of the "traditional" tools, which are a chore to use. I only have a html page with a few JS script, not sure if Deno is the correct tool for what I wanna do.
if you are going for web use, I'd suggest not using yaml at all
If you still need to, you can just fetch() it as text content, right?
await fetch("your_file_url").then(res => res.text())
There was this thing called leaf
Not sure if it still works, but it used to be what you used to sidestep that problem a while ago
@iron flicker I'm sorry, I'm a noob when it comes to web development, and I don't understand the scope of the project. I want to create a webapp, and I'm not sure if Deno is the right tool for that.
After reading again the documentation, it looks like Deno is an alternative to Nodejs, so it should be used for server side. Per the Deno documentation, if I want a bundler to transpile & pack my app together, I should use esbuild, but then I'm back to the npm ecosystem, right?