Importing JSON files?

# Glen Huang (10 years ago)

In nodejs you can require a json file directly to get its value: var value = require(“./package.json”).

Is there an equivalent construct in es2015? Or developers have to turn it into a module before it can be imported?

# caridy (10 years ago)

Glen, better to ask this question on whatwg/loader/issues/new, we will be happy to provide more details since this has nothing to do with ES2015 specifications.

# Glen Huang (10 years ago)

Oh, didn’t know it’s loader’s responsibility. Will give the spec a read (haven’t read it throughly) and post to the issue track if I can’t figure it out.

But just to make sure I will ask the right question, we should write something like import value from “./package.json”; in es2015, and then somehow tell the loader (the part I will explore) the file being imported solely contains a json string, so it can be directly imported?