# @webruntime/api

> Lightning Web Runtime API

Latest version **1.61.4** (published 2021-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @webruntime/api
pnpm add @webruntime/api
yarn add @webruntime/api
bun add @webruntime/api
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.61.4 |
| Published | 2021-07-23 |
| First published | 2020-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 291.8 KB |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| Maintainers | tconn, diervo, zhawtof, kjkimsfdc, lwc-admin |

## Links

- npm: https://www.npmjs.com/package/@webruntime/api
- npm.io page: https://npm.io/package/@webruntime/api

## Dependencies (8)

- [helmet](https://npm.io/package/helmet.md) 4.4.1
- [rollup](https://npm.io/package/rollup.md) 2.33.3
- [express](https://npm.io/package/express.md) 4.17.1
- [deepmerge](https://npm.io/package/deepmerge.md) 4.2.2
- [@lwc/errors](https://npm.io/package/@lwc/errors.md) 2.2.5
- [@lwc/compiler](https://npm.io/package/@lwc/compiler.md) 2.2.5
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) 6.2.0
- [@webruntime/compiler](https://npm.io/package/@webruntime/compiler.md) 1.61.4

## Recent versions

- 1.61.4 (latest) — 2021-07-23
- 0.61.2-234.9 (winter22) — 2021-09-15
- 1.61.5-alpha.1711 (canary) — 2021-07-27
- 0.49.6-232.2 (summer21) — 2021-04-26
- 0.42.6-230.3 (spring21) — 2021-02-11
- 0.33.24-228.1 (winter21) — 2020-08-07
- 0.29.13-226.1 (summer20) — 2020-04-13
- 0.61.2-234.8 — 2021-08-18
- 0.61.2-234.7 — 2021-08-12
- 0.61.2-234.6 — 2021-08-11
- 0.61.2-234.5 — 2021-08-04
- 0.61.2-234.4 — 2021-07-31
- 0.61.2-234.3 — 2021-07-30
- 0.61.2-234.2 — 2021-07-28
- 0.61.2-234.1 — 2021-07-28
- … 285 more at https://npm.io/package/@webruntime/api/versions

## README

# Lightning Web Runtime :: Core API

The Lightning Web Runtime server is a pluggable application server. The Core API package provides the base definitions which describe the Runtime's configuration.

## Configuration

Application configuration and customization is done primarily in `webruntime-app.config.js`. Customization includes:

-   what services the application server will use
-   the page application container to use, which governs the pages rendered by the application
-   how the module bundler ([rollup.js](https://rollupjs.org/guide/en/)) choses which components to bundle together during compilation
-   how components are bundled and provided to the client

### Services Configuration

Addressable Services configuration describes the HTTP addressable services supported by your LWR application.

```js
const { ComponentService, ImportMapService, AppBootstrapService } = require('@webruntime/services');

module.exports = {
    // Addressable Services
    services: [ComponentService, ImportMapService, AppBootstrapService],
};
```

See [Addressable Services API](ADDRESSABLE_SERVICES_API.md)

### Application Configuration

Application configuration defines your application component(s) (an application component is simply a LWC that is the root/parent component of a page), and the page(s) which contain them.

```js
    // Application Configuration
    app: {
        defaultComponent: 'my/app',
        defaultTemplate: 'src/index.html',
    },
```

See [Application API](APPLICATION_API.md)

### Component Rollup

Configuration of how components are bundled together during compilation is described by the [`CompilerConfig.inlineConfig`](docs/modules/_config_.md) configuration property.

When a component is compiled, dependent components can be rolled up in to the component's source. This produces a compiled component with both the root and its dependencies inlined in to the resulting generated code.

The `inlineConfig` property allows you to configure which components are rolled up in to the generated source.

By default, the compiler will attempt to rollup all components available to the compiler. This includes components in the `moduleDir` as well as components provided via package.json dependencies.

As a result, the `inlineConfig` directive is primarily an exclusion policy.

For example the following configuration, will exclude the `shared/library` component from being woven in to the generated code for the `my/app` component. This enables re-use of the `shared/library` component by others via [Component Bundling](#component-bundling) or `externals`.

```javascript
module.exports = {
    // Component Bundling Configuration
    compilerConfig {
        inlineConfig: [{ descriptor: 'my/app', exclude:['shared/library']}],
    }
};
```

**_Note_:** If an exclusion matches an unexposed dependency, the exclusion will be ignored. Unexposed dependencies will always be rolled up.

### Component Bundling

LWR compiles all your application code into manageable code "bundles". This is meant to ensure the application doesn't try to load unnecessary code, while also ensuring that code is available when the application needs it. When LWR creates these bundles, a decision has to be made on how large each bundle should be. The act of drawing that line at a certain boundary is usually referred to as code-splitting. LWR gives you control over the code splitting strategy.

For example, the following configuration directs the runtime to split the application in two ways --

-   bundle all available dependencies of the root component -- `my/app`
-   bundle all available dependencies for each page component -- `pages/*`

The bundle will not include dependendies, which are either preloaded using the `preloadModules` or consider external to the runtime container by the `externals` configuration property.

```javascript
module.exports = {
    // Component Bundling Configuration
    bundle: ['my/app', 'pages/*'],
};
```

**_Note_:** In the case of component bundling the components are still individually registered in to the client component module registry, but are grouped together in to bundled response payload.

#### Bundling Exclusions

It is also possible to exclude components from a bundling request using the `exclude` property in the [Bundle Config Entry](docs/modules/_config_.md#bundleconfigentry).

```javascript
module.exports = {
    // Component Bundling Configuration
    bundle: [{ descriptor: 'my/app', exclude: ['shared/library'] }, 'pages/*'],
};
```

This type of configuration can be useful when you want to share a module across application component graphs. Use in conjunction with `preloadModules` or `externals` configuration properties.

---
_Source: https://npm.io/package/@webruntime/api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
