env-cmd
env-cmd copied to clipboard
refactor: made adding a new loader easier
referencing my comment in #133
turned out to be a very small change.
- js/cjs are loaded with dynamic import
- other ext are mapped against an object 0f
{[exst: string] (src: string) => object}(which currently just contains'.json': JSON.parse) - if ext doesn't have a mapping it falls back to the JSON.parse
This is a very cool PR. I like the simplicity of it + the clarity it adds. Would make it a lot easier to support more file extensions.
@toddbluhm awesome-sauce, I believe the tests only failed because i didn't pre-lint, so thats easily fixable. Now it's been a while since i wrote this and I'm still dealing with the aftermath of a corrupted system-drive on my main machine, so rewisiting the code won't be ultra swift, but i'll take your response as a green-light on polishing this up.
Want me to include YAML and/or JSON5 suport rightaway aswell? I'd suggest to include both, but it's your call.
Any update on this? I'm happy to help get this merged if required. We would really like to use json with comments.
@toddbluhm if you're concerned about adding another dependency you could make it a peerDependency and/or just have a helpful error message if the user tries to use jsonc without that dependency installed. I'm happy to make a PR for this. facebook's create-react-app uses this approach