New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@lwrjs/client-modules

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lwrjs/client-modules

0.0.2-alpha47
84

Supply Chain Security

100

Vulnerability

89

Quality

99

Maintenance

100

License

Version published
Weekly downloads
2.8K
1.44%
Maintainers
8
Weekly downloads
 
Created

Lightning Web Runtime :: Application Initialization

The lwr/init module provides APIs which are responsible for:

This results in the root component(s) being renderable by the DOM on first page load.

Definition

interface InitAPI {
    init(rootModules: [string, LightningElement][]): void;
}

Usage

import { init } from 'lwr/init';
import xAppRoot from 'x/appRoot';
import xNav from 'x/nav';

init([
    ['x/appRoot', xAppRoot],
    ['x/nav', xNav],
]);

Configuration

The default lwr/init module used by an LWR route can be overridden with these steps:

  • Create a module exporting an init function which implements the InitAPI interface:
// src/modules/example/init/init.js
export function init(rootModules) {
    rootModules.forEach(([moduleSpecifier, ctor]) => {
        const elementName = toKebabCase(moduleSpecifier);
        customElements.define(elementName, ctor.CustomElementConstructor);
    });
}
  • Configure the init module specifier in lwr.config.json:
{
    "routes": [
        {
            "id": "example",
            "init": "example/init"
        }
    ]
}

FAQs

Package last updated on 22 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts