Skip to content
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

Support loading JSON "modules" #12

Closed
ghost opened this issue Oct 6, 2020 · 2 comments
Closed

Support loading JSON "modules" #12

ghost opened this issue Oct 6, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 6, 2020

It would be really useful to be able to load JSON "modules" using loadModule. This is a feature supported by Typescript via the resolveJsonModule compiler option.

@klesun
Copy link
Owner

klesun commented Oct 6, 2020

But... but json is not a module...

Can't you just load json file with await fetch('./path/to.json').then(rs => rs.json())? Is there any profit in loading it via an import over a fetch()?

The main purpose of this lib is resolving subdependencies. Adding small nice things like json import, while possible, would needlessly overcomplicate it's already not so easy to understand implementation. So unless there is some use case that make json import a must-have feature, I don't think I'll be adding it here.

I believe resolveJsonModule was added as a workaround to support node's require behaviour which was pretty arguable IMHO and was eventually dropped by the node's authors btw.

This guy's argument is pretty much same as mine.

@ghost
Copy link
Author

ghost commented Oct 6, 2020

While it would be more convenient to use the same system for all purposes, you make a good point that there are existing APIs that fill this need. A need that is probably outside the scope of this project. Closing as such.

@ghost ghost closed this as completed Oct 6, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant