Description
Bug report Change request
(this is not exactly a bug), more a change in behavior request to align with other implementations.
the expected change would be to be consistent with (see below) whatwg/tc39/node.js and treat a json module import as a default import, and do not allow or support named exports.
basically throw a warning, same or similar to what v4 does with js modules not having a named export, e.g.
WARNING in ./src/index.js 3:12-16
"export 'test' was not found in './data.json'
couple reasons for not considering named exports: confusing and non-consistent behavior of "JSON Object" vs "JSON Array" (+ others, "string", null etc.). Also how to handle a "default" property on an "JSON Object".
additional background:
WHATWG
whatwg/html#4315
https://html.spec.whatwg.org/#json-module-script
https://html.spec.whatwg.org/#creating-a-json-module-script (give it some time to load)
Node.js modules working group
nodejs/node#27752
related Rollup issue:
rollup/rollup#2920
** Expected Behavior
// allow
import data from './data.json'
// disallow
import { foo } from './data.json'
this would be a great addition for v5, as it would be a breaking change. not sure about the feasibility of integrating the same in v4 since it's only a warning.
edit: added Rollup issue reference