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

The benefits of supporting JSON modules named exports would outweigh the downsides #22

Open
zbrogz opened this issue Apr 14, 2022 · 0 comments

Comments

@zbrogz
Copy link

zbrogz commented Apr 14, 2022

Summary

Respectfully, I believe not supporting named exports with JSON modules was the wrong decision. Importing JSON modules with named exports is indeed more ergonomic and lends itself to tree shaking.

This was a useful feature in Webpack, but is in the process of being removed due to this proposal. See webpack/webpack#9246

Response to reasons given

From: https://github.com/tc39/proposal-json-modules#why-dont-json-modules-support-named-exports

They are not fully general: not all JSON documents are objects, and not all object property keys are JavaScript identifiers that can be bound as named imports.

Sure, but that doesn't mean it wouldn't be useful. I would prefer to have the feature available even if it has limitations.

It makes sense to think of a JSON document as conceptually whatwg/html#4315 (comment) rather than several things that happen to be side-by-side in a file.

I think it can also make sense to think of a JSON document in terms of different importable fields.

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