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.

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.

Fields

Field Name Field Type Description
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 description of the Lightning web component.
isExplicitImport boolean Indicates whether imports between files are done explicitly by the developer (true) or implicitly by the framework (false).
isExposed boolean Indicates whether a component is usable in a managed package (true) or not (false).
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 is supported. Each target is a Lightning page type that can be configured in Lightning App Builder.

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.

Field Field Type Description
capability string Specifies something that a component can do. The only valid value is lightningCommunity__RelaxedCSP, which enables a component installed from a managed package to run in an Experience Cloud site that has Lightning Locker disabled.

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.

Field Field Type Description
target string Specifies the type of Lightning page the component can be added to in Lightning App Builder.
Valid values are:
  • lightning__AppPage—Enables a component to be used on a Lightning app page.
  • lightning__HomePage—Enables a component to be used on a custom Lightning Home page.
  • lightning__RecordPage—Enables a component to be used on a Lightning record page, such as Account or Contact.

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, track } from 'lwc';
2
3export default class Hello extends LightningElement {
4    @track 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.