rescript-lang.org icon indicating copy to clipboard operation
rescript-lang.org copied to clipboard

Add "Import a JSON file content" to "Import From JavaScript" page

Open MoOx opened this issue 4 years ago • 3 comments

Could be handy for new comers or eternal newbies like me.

MoOx avatar Jan 17 '21 07:01 MoOx

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?

ryyppy avatar Jan 25 '21 09:01 ryyppy

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.

MoOx avatar Jan 25 '21 10:01 MoOx

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!

ryyppy avatar Sep 08 '21 18:09 ryyppy