[SalesForce] Can we See the lwc Module

This page in the LWC developer guide talks about a component JS file, in particular:

Every UI component must include a JavaScript file with at least this code.

import { LightningElement } from 'lwc';
    export default class MyComponent extends LightningElement {
}

The core module in Lightning Web Components is lwc. The import statement imports LightningElement from the lwc module.

import { LightningElement } from 'lwc';

LightningElement is a custom wrapper of the standard HTML element.

Presently I'm learning about JS modules and importing/exporting them. I understand that they are individual JS files.

So is there a way to see the lwc module referenced in the documentation? If possible, what is in it and what does it look like?

Best Answer

Edit (2019-05-30): LWC is now open source! https://github.com/salesforce/lwc

Our intent is to open source LWC by the end of the year but it will ultimately come down to resourcing constraints because there's still a lot of work to do!

There's not too much going on in the lwc module. There's basically LightningElement which exposes an API subset of HTMLElement (what we consider the "good parts"). There are also the various decorators (api, track, readonly, wire) and several other APIs that are only usable by our compiler.

To answer your question though, a single file would be the simplest type of module, but a module can contain multiple files since we are able to import and export in the same file. You can event do that with a single line using module redirects.

Related Topic