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

whatwg/tc39/node.js JSON modules #2920

Closed
dnalborczyk opened this issue Jun 10, 2019 · 3 comments
Closed

whatwg/tc39/node.js JSON modules #2920

dnalborczyk opened this issue Jun 10, 2019 · 3 comments

Comments

@dnalborczyk
Copy link
Contributor

dnalborczyk commented Jun 10, 2019

consider deprecating the rollup json plugin https://github.com/rollup/rollup-plugin-json and pull in core functionality into rollup main, with some changes in behavior.

the expected change would be to be consistent with (see below) whatwg/tc39/node.js and treat the json import as a default import, and do not allow or support named exports .

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".

if the separate json plugin is still a better option, it would be still great to adopt the consensus of not allowing named exports to have the same expectations working across browsers, engines and tools.

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)

TC39 https://docs.google.com/presentation/d/1w8jWjD41htD7VxOejFqiHi6uGgHVWtZ_XmgFxgKkS7Q/edit#slide=id.g5947c7781f_0_20

Node.js modules working group
nodejs/node#27752

related Webpack issue:
webpack/webpack#9246

Expected Behavior / Situation

// allow
import data from './data.json'

// disallow, throw
import { foo } from './data.json'

Actual Behavior / Situation

Modification Proposal

edit: modified reasons section, added webpack issue reference

@shellscape
Copy link
Contributor

@lukastaegert what are your thoughts on this? I don't personally have an issue with JSON module support being external. But it seems everyone and their brother has integrated it into their core.

@lukastaegert
Copy link
Member

If it becomes an official feature, we could put it into core. But there will still be need for rollup-plugin-json as property tree-shaking is a useful feature that even Rollup itself relies upon. I would see this as a nice-to-have.

@dnalborczyk
Copy link
Contributor Author

this proposal was the precursor to import assertions and can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants