-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider supporting importing files as jsonc
/ json5
#20374
Comments
Although it may seem like a practical inclusion, I worry that it's straying away from web spec. How would we decide which formats to allow? Would |
Even though I agree with @lino-levan, since Deno supports |
Outside of static analysis, this doesn't provide a lot of benefit imo. Are there enough people asking for |
i'd like to share my use-use:
it's more of an workaround, however once deno exposes fmt as an runtime API (#10731). |
Perhaps #19322 would be a less hacky way of doing it while not exposing a runtime API? |
JSON is a great (de-)serialization format for apps' configs and data. As a modern application environment, it would be great to be able to use Following #20833, please add support importing files as |
jsonc
jsonc
/ json5
Also note that JSON5 is arguably a better spec than JSONC, see microsoft/vscode#100688 |
JSON imports as per https://docs.deno.com/examples/importing-json/ won't recognize .jsonc files. There's an issue at denoland/deno#20374 about supporting importing .jsonc/.json5 files as well but doesn't seem to have much momentum. Feels best not to fight this battle right now.
I think That means that doing Note that if you don't want to use
Cascading implicationsYou could argue the compiler strictness around Some people have even suggested allowing to remove the import assertion entirely with a flag like #26157 |
How about just allowing importing JSONc as JSON with its comments stripped away? import data from "./data.jsonc" with { type: "json" } related: https://douglascrockfordisnotyourdad.technomancy.us |
Be careful because the behavior of If you wanted to go this option, Deno would need to generate extra code when transpiling to vanilla JS for browsers when it seems It also doesn't solve the problem that some projects use |
import data from "./data.jsonc" with { type: "jsonc" };
import data from "./data.json5" with { type: "json5" };
I'm not to sure about this myself yet, but it may be interesting. What are peoples' thoughts?
The text was updated successfully, but these errors were encountered: