Status: REJECTED

Champion: Unknown

Revision: latest

RFC created: 1970/01/01

Last updated: unknown

This RFC has been merged

Platform Metadata

Define a way to signal when a Lightning Web Components bundle is global (platform available), plus the minimum set of metadata required by our platform to operate.

Requirements

Proposals

Proposal 1: Descriptor File lightning.json

{
    "description": "some text",
    "minVersion": "1",
    "maxVersion": "2"
}

Pros:

Cons:

Proposal 2: Descriptor File package.json (no-go: too confusing)

{
    "name": "something",
    "description": "some text",
    "module": "new.js",
    "salesforce": {
        "minVersion": "1",
        "maxVersion": "2"
    }
}

Cons:

Proposal 3: Comment on Class Declaration

// @platform min=1, max=2
import { LightningElement } from "lwc";
export default class Foo extends Element {
    // ...
}

Similar to eslint flags:

Pros:

Cons:

Resolution

We have decided to go with Proposal 1.

Versioning

It seems that somehow a runtime forking logic might be needed. We haven't found problems like this, but if they arise, we better be prepared.

Proposal 1: Runtime Logic Fork on Version

import { LightningElement } from "lwc";
export default class Foo extends Element {
    handleClick() {
        if (this.version === 23) {
            this.dispatchEvent(new CustomEvent('expand', { bubbles: true }));
        }
    }
}

In this case, Element implements a getter for version that can come from the vnode instantiation process. This should be fairly simple to implement, we just need, somehow, that the compiler provides a vnode.data.version value as part of the instance creation mechanism for custom elements, so Element can surface that value at runtime, e.g.:

export function html(cmp, api, slotset, memoizer) {
    return [
        api.c('x-foo', { data: { props: { x: 1 }, version: 30 } })
    ];
}

This will prevent false possitive breakages when a developer makes a mistake, or assumes that something is not defined, or do not expect events coming from a custom element, where a new version of the custom element, while still backward compatible, breaks the wrong assumptions of the consumer.

Open Questions

Annexes

undefined