-
Notifications
You must be signed in to change notification settings - Fork 20
Description
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.