-
Notifications
You must be signed in to change notification settings - Fork 58
allow importing JS files too #25
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
Conversation
|
@vieron Thanks for the PR! I've already turned down a request for the same functionality but perhaps it should be reconsidered. My hesitation is that "importing a JS file" can mean so many different things. In both this PR and the issue referenced, "importing a JS file" essentially means importing JSON format exported via CommonJS in a JS file, but if someone tried to import a "regular" JS file, the importer would break. By contrast, JSON is a much stricter format and easier to reason about. What's your use-case? Why not just make it a JSON file to begin with? |
|
Hi @pmowrer! The reasons why I prefer JS over JSON are:
I agree importing JS isn't as robust as JSON, and it could break the importer. But we could JSON.stringify and then JSON.parse the value of What do you think? |
|
I think those are good points. My main hesitation is that if someone wrote another importer that targeted JS files for some other reasons, they wouldn't be able to use this importer at the same time b/c they'd block each other. A way of limiting that type of collision would be to return |
|
Thanks for the answer @pmowrer! |
|
Sorry, I read too fast. If you don't feel comfortable having js support in this importer, I can move it to a separate repo and name it |
|
I think it makes sense in this importer so long as we ignore JS files that aren't exporting JSON. |
|
Ready for review! |
| }); | ||
|
|
||
| expect(result.css.toString()).to.eql(EXPECTATION); | ||
| it(`strips non-valid JSON values from JS exports`, function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test title doesn't seem to match the test expectation ("strip" vs "throw")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right!
|
Closing due to inactivity |
cc/ @pmowrer