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

have a plugin for being able to import JSON using ESM #516

Closed
1 of 5 tasks
thescientist13 opened this issue Apr 10, 2021 · 1 comment · Fixed by #615
Closed
1 of 5 tasks

have a plugin for being able to import JSON using ESM #516

thescientist13 opened this issue Apr 10, 2021 · 1 comment · Fixed by #615
Assignees
Labels
CLI discussion tied to an ongoing discussion or meeting notes good first issue Good for newcomers Plugins Greenwood Plugins v0.13.0 website Tasks related to the projects website / documentation
Milestone

Comments

@thescientist13
Copy link
Member

Type of Change

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

Summary

As is the case with CSS, being able to use import with JSON is against the spec, and so this sort of behavior should be moved into a plugin, instead of being supported by default by the CLI.

Details

Currently this is supported by default but shouldn't be so we should extract this code into a standalone package; plugin-import-json.

const json = await fs.promises.readFile(url, 'utf-8');

contentType = 'text/javascript';
body = `export default ${json}`;

I don't know if this will have any impact on just using fetch for .json so should just do some basic sanity checking. This plugin will then need to be added to greenwood.config.js

@thescientist13 thescientist13 added good first issue Good for newcomers website Tasks related to the projects website / documentation Plugins Greenwood Plugins CLI labels Apr 10, 2021
@thescientist13 thescientist13 added this to the 1.0 milestone Apr 10, 2021
@thescientist13 thescientist13 changed the title Import JSON plugin have a plugin for being able to import JSON using ESM Apr 10, 2021
@thescientist13 thescientist13 added the help wanted Extra attention is needed label May 15, 2021
@thescientist13 thescientist13 self-assigned this May 15, 2021
@thescientist13
Copy link
Member Author

Started a discussion for this here - #606

@thescientist13 thescientist13 added discussion tied to an ongoing discussion or meeting notes and removed help wanted Extra attention is needed labels May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI discussion tied to an ongoing discussion or meeting notes good first issue Good for newcomers Plugins Greenwood Plugins v0.13.0 website Tasks related to the projects website / documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant