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

fetching any JSON file that is not graph.json always returns an ES module #604

Closed
1 of 5 tasks
thescientist13 opened this issue May 15, 2021 · 0 comments · Fixed by #605
Closed
1 of 5 tasks

fetching any JSON file that is not graph.json always returns an ES module #604

thescientist13 opened this issue May 15, 2021 · 0 comments · Fixed by #605
Assignees
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP v0.12.3
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented May 15, 2021

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

Just noticed as part of working on #516 that if you try and do something like this

<script type="module">
  fetch('/data.json')
    .then(resp => resp.json())
    .then(resp => console.debug('DATA', resp));
</script>

Based on our current logic, it will always come back as ESM, e.g.

export default { ... }

When it should just come back as the exact contents.

Details

This also uncovers another issue related to how we should be able to support using ESM with non standard module types like JSON and images, since import just uses fetch, to a browser, a request for JSON, to a browser they both look the same, so there is currently no way for us to distinguish the differences between these two

<script type="module">
  fetch('/data.json')
    .then(resp => resp.json())
    .then(resp => console.debug('DATA', resp));
</script>
import json from '/package.json';

Will need to setup a discussion for this and drop down to using an internal API for now that can get "hints" along the lines of import assertions to help keep us moving, ex.

import json from '/package.json?type=json';

However, this need for query params is dependent on #599 and requires a bit of a work around for now, so needing to make an exception to solve both at the same time.

@thescientist13 thescientist13 added bug Something isn't working P0 Critical issue that should get addressed ASAP CLI labels May 15, 2021
@thescientist13 thescientist13 added this to the 1.0 milestone May 15, 2021
@thescientist13 thescientist13 self-assigned this May 15, 2021
@thescientist13 thescientist13 changed the title fetching any JSON file that is _not_ graph.json always returns an ES module fetching any JSON file that is not graph.json always returns an ES module May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP v0.12.3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant