lit / lit/lit

[labs/gen-manifest] produce events/atrributes for mixins

Open
#4,683 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
21.8k
Forks
1.1k
Avg merge
18h 25m
Merged PRs (30d)
2

Description

### Should this be an RFC?

- [X] This is not a substantial change

### Which package is this a feature request for?

Analyzer (@lit-labs/analyzer)

### Description

Hi,

I have a question/suggestion regarding custom-elements.json manifst generation.

`@lit-labs/cli gen --manifest` produces a manifest where mixins for a component class are listed and linked in the class description (`mixins` field).

If I read this [comment](https://github.com/lit/lit/issues/4529#issuecomment-1915825290) correctly, downstream tooling is supposed to resolve these references (i.e. inherited, or "mixed-in" traits). They are not flattened to the class description in the manifest. This makes sense.

However, if a mixin contributes events, properties, etc.. these should be at least listed as part of the mixin description in the manifest then. From what I have tried and from what I can tell [from the code](https://github.com/lit/lit/blob/497422780bb061bae3585579dcf842c2b411e5fb/packages/labs/gen-manifest/src/index.ts#L224), currently, mixins are (correctly) treaded as functions. I also could not find test fixtures that cover this. So currently I don't see a way to transitively extract all mixin contributions to a component class from the manifest.
In practice discovering annotations from either the mixin function, the class that is constructed within the mixin, or the returned interface could be a way to transport things like @fires annotations and properties.

### Alternatives and Workarounds

* Looking through the code, I get the impression that [there are, in principle, plans to add dedicated emission code for mixins](https://github.com/lit/lit/blob/497422780bb061bae3585579dcf842c2b411e5fb/packages/labs/gen-manifest/src/index.ts#L138). Is this understanding correct?
* If not, is there currently a way to annotate mixins so that events, attributes and properties which they contribute can be discovered in the manifest?

On a side note if many hops are required to collect all the metadata for a component in a custom-elements.json manifest it maybe does make sense to have mode where the data is flattened, for the sake of simplicity for users..

Contributor guide

Open the contributing guide

Research direction

Start in packages/labs/gen-manifest/src/index.ts, especially the mixin handling around lines 138 and 224, and inspect the analyzer's existing manifest-generation tests and fixtures. Define how mixin-contributed events, attributes, and properties should appear in custom-elements.json, add coverage for the relevant mixin cases, and verify the generated manifest contains the expected metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.