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

Bug/issue 604 fix json fetch handling #605

Merged
merged 7 commits into from
May 27, 2021

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented May 15, 2021

resolves #604

Summary of Changes

  1. For now, have to add an "internal" API to capture originalUrl as a header to play nicely with make resource resolving more graceful and fallback to original ctx.url #599 wherein if we have query strings in URLs against the filesystem, then things will break, so need to preserve query params another way
  2. Adapted plugin-standard-json accordingly, and then the ?type=json logic of this will get extracted out into have a plugin for being able to import JSON using ESM #516

As with anything non standard, this is no "right way" per se to solve this. So far the best hint I can come up with is this

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

Which takes some influence from a potential standard called import assertions
https://github.com/tc39/proposal-import-assertions

TODO

  1. Add some tests
  2. Setup a discussion to review best way forward for things like have a plugin for being able to import JSON using ESM #516 and other assets like CSS and potentially images - Using `import` for non JavaScript modules #606
  3. Clean up test code

@thescientist13 thescientist13 added bug Something isn't working P0 Critical issue that should get addressed ASAP Plugins Greenwood Plugins CLI labels May 15, 2021
@thescientist13 thescientist13 self-assigned this May 15, 2021
@thescientist13 thescientist13 removed the Plugins Greenwood Plugins label May 15, 2021
@thescientist13 thescientist13 marked this pull request as ready for review May 15, 2021 21:57
@thescientist13 thescientist13 added the discussion tied to an ongoing discussion or meeting notes label May 15, 2021
@thescientist13 thescientist13 force-pushed the bug/issue-604-fix-json-fetch-handling branch from 866bce4 to eef8f42 Compare May 16, 2021 00:16
@thescientist13 thescientist13 merged commit 8a0b5e0 into master May 27, 2021
@thescientist13 thescientist13 deleted the bug/issue-604-fix-json-fetch-handling branch May 27, 2021 16:47
@thescientist13 thescientist13 removed their assignment Jun 5, 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 discussion tied to an ongoing discussion or meeting notes P0 Critical issue that should get addressed ASAP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fetching any JSON file that is not graph.json always returns an ES module
1 participant