Newer Version Available

This content describes an older version of this product. View Latest

LightningComponentBundle

Represents a Lightning web component bundle. A bundle contains Lightning web component resources.

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Important

Special Access Rules

LightningComponentBundle components can be created only in orgs with defined namespaces.

As of Summer ’20 and later, only your Salesforce org's internal users can access this type.

For more information on packaging a Lightning web component bundle, see the Second-Generation Managed Packaging Developer Guide.

Fields

Field Name Field Type Description
ai (Beta) base64Binary An internal AI description of the Lightning web component. This description is supported only in orgs that have Setup with Agentforce (Beta) enabled. This description enables Agentforce to analyze the component for inclusion in agent-generated Lightning pages. For more information, see Configure a Component for Use in Setup with Agentforce (Beta).
1<ai>
2    <description>AI component description Example: The component enables users to add and style text content for dashboards, supporting features such as hyperlinks, bullet points, and text alignment. Ideal for adding formatted text sections such as instructions</description>
3    <property name="prop1" aiDescription="AI description for prop1"/>
4    <property name="prop2" aiDescription="AI description for prop2"/>
5</ai>

Available in API version 66.0 and later.

apiVersion double A double value that binds the component to a Salesforce API version.
capabilities Capabilities[] A list of capabilities. A capability is something that a component can do, as opposed to a target, which defines where you can use a component. Available in API version 48.0 and later.
description string A user-facing description of the Lightning web component. This description appears in list views, like the list of Lightning Components in Setup, and as a tooltip in the builders like Lightning App Builder and Experience Builder.
isExplicitImport boolean Indicates whether imports between files are done explicitly by the developer (true) or implicitly by the framework (false).
isExposed boolean If true, the component is available to other namespaces. If true and a targets value is also provided, the component is available to Salesforce builders such as Lightning App Builder and Experience Builder. If false, the component isn't available to builders and other namespaces.
lwcResources LwcResources[] A list of resources inside a bundle.
masterLabel string The component title that appears in the list view.
targetConfigs base64Binary Configurations for each target. Each target is a Lightning page type. For example, this configuration allows a Lightning web component to be used on a Contact record page in Lightning App Builder.
1<targetConfigs>
2    <targetConfig targets="lightning__RecordPage">
3        <objects>
4            <object>Contact</object>
5        </objects>
6    </targetConfig>
7</targetConfigs>
targets Targets[] A list of targets where the Lightning web component can be used, such as in Lightning App Builder or Experience Builder sites.

Capabilities

Represents a list of capabilities. A capability is something that a component can do, as opposed to a target, which defines where you can use a component. Available in API version 48.0 and later. For more information, see XML Configuration File Elements.

Field Field Type Description
capability string Specifies something that a component can do. Valid values are:
  • lightningCommunity__RelaxedCSP
  • lightning__dynamicComponent
  • lightning__ServerRenderable
  • lightning__ServerRenderableWithHydration
  • lightning__ServiceCloudVoiceToolkitApi

LwcResources

Represents a list of resources inside a LightningComponentBundle.

Field Field Type Description
lwcResource LwcResource A resource inside a LightningComponentBundle.

LwcResource

Represents a resource inside a LightningComponentBundle.

Field Field Type Description
filePath string Required. The file path of a resource.
source base64Binary Required. The content of a resource.

Targets

Represents a list of supported containers for a Lightning web component. For more information, see XML Configuration File Elements.

Field Field Type Description
target string Specifies the type of Lightning page the component can be added to in the builders, such as in Lightning App Builder, Experience Builder, Flow Builder, or Document Builder.

For valid values, see XML Configuration File Elements: target.

Declarative Metadata Sample Definition

This package.xml file retrieves all the LightningComponentBundle components in an org.
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>*</members>
5        <name>LightningComponentBundle</name>
6    </types>
7    <version>45.0</version>
8</Package>

In the retrieved zip file, each Lightning web component is nested under an lwc folder.

This example shows the directory structure in the zip file of one component with a name of hello.

1lwc
2    hello
3        hello.html
4        hello.js
5        hello.js-meta.xml

Here are the contents of the files in the hello directory.

Content of hello.html:

1<template>
2
3    <lightning-card title="Hello" icon-name="custom:custom14">
4        <div class="slds-m-around_medium">
5            Hello, {greeting}!
6        </div>
7    </lightning-card>
8
9</template>

Content of hello.js:

1import { LightningElement } from 'lwc';
2
3export default class Hello extends LightningElement {
4    greeting = 'World';
5}
Content of hello.js-meta.xml.
1<?xml version="1.0" encoding="UTF-8"?>
2<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3    <apiVersion>45.0</apiVersion>
4    <isExposed>true</isExposed>
5    <targets>
6        <target>lightning__AppPage</target>
7        <target>lightning__RecordPage</target>
8        <target>lightning__HomePage</target>
9    </targets>
10</LightningComponentBundle>

Wildcard Support in the Manifest File

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.