rescript-lang.org
rescript-lang.org copied to clipboard
Add "Import a JSON file content" to "Import From JavaScript" page
Could be handy for new comers or eternal newbies like me.
I think this particular example is too concrete. Import / Export talks about how to interop with different module kinds.
Maybe it would be better to put that in the Cheatsheet in the JS Module Interop section instead?
Yeah maybe. Also my example is incomplete as it's not the same thing that's need to be written depending on you package-specs.module value (es6 or commonjs)
I wrote
@bs.module external studentNames: dataType = "./students.json"
That's for commonjs.
For es6 you need to write
@bs.module("./students.json") external studentNames: dataType = "default"
Anyway this definitely needs to be somewhere in the doc. I am doing ReScript/Reason for while now (not 100% of my weeks but still) and I always find my self to check doc for this to not have to think about it.
Alriiight, I think we want to have this in, but the PR is a little outdated. Will copy over the changes and do some adaptions!