-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
esm: decouple json modules from cjs cache #30592
Conversation
It seems like this change would mean that mutating a required JSON would no longer be visible from an imported JSON, and vice versa. Could you elaborate on why this change is a good thing? |
@ljharb this more closely matches how web is looking at introducing JSON modules in a variety of ways. In particular the coupling seems problematic to assumption of module attributes being able to assert that loading JSON does not introduce side effects. In addition, JSON modules on the web get unique cache entries per URL, the current implementation by using the CJS loading mechanism ignores URL query and fragments. I'm not sure preserving mutating JSON as a feature has been weighed against web compatibility concerns and this is a PR that could encourage that discussion. I personally think that mutating JSON isn't the highest priority feature, and the leveraging of cache busting via URL leads to odd behavior coordination for users as seen in nodejs/modules#417 . For CJS, that seems fine as there isn't another runtime interoperability being proposed, however for JSON there is some interoperability discussion to be had. |
Do we have an issue / agenda item for this to discuss further? It would help to understand the full motivations again here. |
@guybedford right now the topics are kind of spread out, I think discussing it here might be a place to coordinate. Mostly this deals with compatibility and expectations and the few links above for now. I could probably tie it to other issues, but nothing really seems to be pressing except those 2.
|
8ae28ff
to
2935f72
Compare
closing as this looks to be deferred to JSON modules which are landing in the spec |
I've opened this to discuss implementation issues with JSON modules on web and/or module attributes that could arise from the coupling as briefly mentioned in the Modules WG meeting. This is not meant to land while discussion (in particular about module attributes) continues.
CC: @nodejs/modules
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes