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

Missing support for dependency discovery in JSON-LD for schemas #1935

Closed
bre7 opened this issue Aug 24, 2018 · 3 comments
Closed

Missing support for dependency discovery in JSON-LD for schemas #1935

bre7 opened this issue Aug 24, 2018 · 3 comments

Comments

@bre7
Copy link
Contributor

bre7 commented Aug 24, 2018

https://github.com/parcel-bundler/parcel/blob/master/src/assets/HTMLAsset.js#L64 JSON is skipped. I know schema.org specs are quite extensive but there are a few basics: image / logo for assets.

🙋 feature request

Assets used in JSON-LD schemas aren't added to the dependency tree. And as a result are missing from builds.

🤔 Expected Behavior

A minimal subset of the attributes should be included in parcel, just like it was done with Open Graph, etc: #747

😯 Current Behavior

Nothing happens since application/ld+json scripts aren't recognized.

💁 Possible Solution

Parse JSON, fetch attributes that match a list (almost the same as #747) and finally add them as dependencies.

💻 Examples

<script type="application/ld+json">
{
  "@context": "http://www.schema.org",
  "@type": "xxx",
  "name": "Parcel Bundler",
  "url": "https://parcel.url/",
  "image": "./images/header.jpeg",
  "logo": "./images/logo.png"
}
</script>
@bre7
Copy link
Contributor Author

bre7 commented Aug 25, 2018

Update: Made a (quick) plugin for it: https://github.com/bre7/parcel-plugin-schemaorg

Not sure if this will be considered as a core functionality. (thanks Jasper for the template 😉)

@devongovett
Copy link
Member

Very cool. Would you like to make a PR to add that to core? I think it will be much easier to maintain there without depending on the internal implementation details of HTMLAsset in a plugin.

@bre7
Copy link
Contributor Author

bre7 commented Aug 25, 2018

Sure, but there's a critical issue that needs fixing first (and I'm not really sure how to do it): paths aren't allowed, only full URLs. How can Parcel deal with it ?

I did think about a possible workaround:

  • Assume the user will enter a valid URL (warn otherwise)
  • When parsing the schema, extract the path and treat it as any local path
  • Resolve dependency
  • Write back the URL + collected path

Current:

<script type="application/ld+json">
{
  "image": "/images/header.a9i39we.jpeg",
  "logo": "/images/logo.aa4d5d5.png"
}
</script>

Expected

<script type="application/ld+json">
{
  "image": "https://parceljs.org/images/header.a9i39we.jpeg",
  "logo": "https://parceljs.org/images/logo.aa4d5d5.png"
}
</script>

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