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

Add a meta tag to indicate custom elements manifest location on webpage #70

Closed
wants to merge 1 commit into from

Conversation

Matsuuu
Copy link

@Matsuuu Matsuuu commented Jun 30, 2021

As in some situations, the tooling might not have access to a package.json, it would be beneficial to be able to indicate the location of the custom elements manifest in the html page. A meta tag should be enough for this.

@Matsuuu
Copy link
Author

Matsuuu commented Jul 1, 2021

An implementation of a simple fetcher would be just a few lines of javascript. This is the example I wrote for DevTools for this. This would allow shipped pages to easily inform tooling where you can find the current page's CEM

export function getCustomElementsManifestUrl() {
        const origin = window.location.origin;
        
        const metaTag = /** @type {HTMLMetaElement} */ (document.querySelector("meta[name='custom-elements-manifest']"));
        if (metaTag) return origin + "/" + metaTag.content;
        
        return origin + '/custom-elements.json';
}

In order to allow tools that don't have access to the package.json property to discover the element manifests, a meta-tag should be used to indicate the location of the custom elements manifest:

```html
<meta name="custom-elements-manifest" content="custom-elements.json" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to answer the questions here: #71 (comment)

And I think a lot of the information in the manifest is likely to be invalid once deployed to pages (modules won't exist if the page has been bundled), plus there is missing information that's only available when you know the package or have the package.json, like the package name and version.

I'd personally like to see examples of this working before making a recommendation to do this, and then I suspect we'd need a lot more detail on how to set this up so that it actually works. I don't think just referencing a manifest from an npm package is going to work very often.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the earlier discussion on the subject and seeing where the CEM is evolving, I too am starting to feel that this might not be an approach worth supporting. You make a great point in the fact that as the package gets deployed, it doesn't have the modules anymore as it most likely is bundled.

I remember the initial discussion for this was around the time people were thinking of ways to support CEM and discussions on how Web Component DevTools could utiize published CEM's. The approach WCDT went doesn't require published CEM's anymore, as it bundles the analyzer with itself, and trying to think of good usecases for these links to CEM on a HTML page, I can't really come up with any.

So I think this idea could be laid to rest and this PR and the linked issue could be closed for now.

@Matsuuu Matsuuu closed this Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants