LightningComponentBundle represents a Lightning web component (LWC) and its bundled resources. It combines implementation files with configuration that describes where the component can be offered and which capabilities it declares. The bundle defines the component, not a placement of that component on a particular page.
A bundle can contain JavaScript, HTML, and a .js-meta.xml configuration file. The configuration file controls exposure and supported containers, but it does not describe all implementation behavior or dependencies. For example, a dependency on an Apex class can appear in a JavaScript import rather than in the configuration file.
Key Elements
| Element | What the Element Controls |
|---|---|
apiVersion |
Binds the component to a Salesforce API version. This stored component setting is distinct from the API version a tool uses to retrieve or deploy metadata. |
isExposed |
If false, the component is unavailable to builders and other namespaces. If true, it is available to other namespaces; builder availability also requires targets. |
targets |
Lists supported containers through target entries. Examples include lightning__AppPage, lightning__RecordPage, and lightning__HomePage. |
targetConfigs |
Provides target-specific configuration, including component properties and supported objects. A targetConfig with targets="lightning__RecordPage" can specify Contact under objects/object. |
capabilities |
Declares what the component can do through capability entries. Documented values are lightningCommunity__RelaxedCSP, lightning__dynamicComponent, lightning__ServerRenderable, lightning__ServerRenderableWithHydration, and lightning__ServiceCloudVoiceToolkitApi. |
lwcResources |
Contains resources inside the bundle through the LwcResources and LwcResource helper structures. These resources are not separate LightningComponentBundle assets. |
filePath |
Required within each resource. Identifies the resource's file path. |
source |
Required within each resource. Contains the resource content; Metadata API represents this field as base64Binary. |
description |
User-facing explanatory text shown in Setup list views and builder tooltips. |
ai |
Internal description that helps Agentforce analyze the component for inclusion in agent-generated Lightning pages. Supported only when Setup with Agentforce is enabled. |
masterLabel |
The component title displayed in the list view. |
isExplicitImport |
Indicates whether imports between files are handled explicitly by the developer (true) or implicitly by the framework (false). |
Behavior and Constraints
Metadata access is separate from component exposure. The documented Metadata API creation rule requires an org with a defined namespace. Access to this metadata type is limited to internal org users. These rules concern metadata access; they are separate from whether a component is exposed to builders or other namespaces.
Read exposure settings together. Setting isExposed to true does not, by itself, make a component available in Lightning App Builder or Experience Builder. The component also needs an appropriate entry in targets. Its targetConfigs then supplies configuration for particular targets.
For example, lightning__RecordPage identifies a supported container, while a corresponding targetConfig containing objects/object with the value Contact describes its use on Contact record pages. Neither setting proves that an admin has placed the component on a page. Also, isExposed is not a user permission and does not grant access to data displayed by component code.
Capabilities do not replace targets. A capability describes something the component can do; a target describes where it can be used. Declaring a capability does not replace builder exposure and targeting. See the XML configuration elements and the supported target values for configuration details.
User-facing and AI descriptions serve different purposes. Use description for explanatory text in Setup and builder tooltips. The ai configuration supplies an internal component description for Agentforce and can include component-level description text and property-level aiDescription annotations. It requires Setup with Agentforce to be enabled. See Agentforce component configuration for details.
Deployment and Retrieval
LightningComponentBundle supports the wildcard * in package.xml. To retrieve all bundles, include this type entry inside the manifest's Package element:
<types><members>*</members><name>LightningComponentBundle</name></types>
In the retrieved ZIP archive, each component is nested under an lwc folder. For example, a component named hello can contain lwc/hello/hello.html, lwc/hello/hello.js, and lwc/hello/hello.js-meta.xml. The implementation resources and configuration belong to the same bundle.
API representation is not the on-disk format. Metadata API types resource source, targetConfigs, and ai as base64Binary. This does not mean that their on-disk contents should be replaced with base64 text. Declarative configuration uses nested XML for targetConfigs and ai, and retrieved implementation resources contain their normal source text.
When a deployment fails, inspect both the bundle's implementation files and the generated deployment contents. JavaScript imports can identify Apex dependencies that are not apparent in .js-meta.xml. Errors mentioning package.xml and a missing ZIP entry can concern how local source was packaged, even when the deployment command did not use a hand-written manifest.
For managed packaging details, see Lightning web component packaging.
Relationships
Implementation resources can carry dependencies that are not dedicated top-level bundle configuration elements. In particular, an Apex import identifies a class that must be available in the destination org for the reported deployment case below. The LwcResources and LwcResource structures contain bundle content; they are not independently deployed bundle assets.
References
-
ApexClass: bundled resourcesourcecan contain a JavaScript import such as@salesforce/apex/LeaveSettingsController.getRoles. This is an embedded code dependency, not a dedicated top-level XML reference element.
Reported Issues
These reports describe diagnostic cases, not exhaustive error definitions or guaranteed remedies.
-
A missing imported Apex class was reported to block deployment. In a 2019 scratch-org report, the error was
Unable to find Apex action class referenced as 'LeaveSettingsController'. The component imported@salesforce/apex/LeaveSettingsController.getRoles, but the class existed only in the Dev Hub. Another answer reported the same problem after omittingApexClassfrom a component-only deployment. The relevant dependency is the class named in the actual import and its availability in the destination org. Apex dependency deployment discussion. -
No base file for markup://c:lwcdndwas reported for problems with the bundle's own files or deployment path. Reports from 2019 and 2020 associated this message with inconsistent component filenames and enclosing component-directory names, case mismatches in the deployment path, and an HTML-only component directory missing its JavaScript and configuration files. The message did not necessarily mean that another component referenced the named component. Base-file error discussion. -
Empty local component directories were reported to cause a manifest-versus-archive error. In a 2023 CLI deployment report, components were reported as
named in package.xml, but was not found in zipped directory. The locallwcfolder contained emptyparentandchilddirectories. Removing those empty directories resolved that case; the message was not evidence that a component was missing from the destination org. Empty-directory deployment report. -
Inconsistent exclusion of component content was reported to produce the same manifest-versus-archive error. In 2021 reports involving
pubsub,.forceignorehandling excluded component content inconsistently during source deployment. The reports differed between command-line and VS Code deployment paths. They support checking the generated deployment contents and exclusion rules, not treating folder removal or a particular ignore-pattern change as universally necessary. Ignore-rule deployment discussion. - A retrieval warning that a bundle could not be found accompanied a reported local authorization problem. In a 2022 report, a component appeared in Setup, but retrieval returned no results and said the bundle could not be found. The author then found that the CLI listed no authorized orgs and reported recovery after reinstalling the CLI and clearing its authorizations. This was a reported tooling and authorization case, not proof that the bundle was absent. Retrieval authorization report.
Common Questions
How do I retrieve all Lightning web components with package.xml?
Add a types entry with members set to * and name set to LightningComponentBundle. Retrieved bundles appear under the archive's lwc folder.
Why is my LWC missing from Lightning App Builder when isExposed is true?
isExposed=true is only part of builder availability. The bundle also needs an appropriate targets entry. Read any target-specific settings in targetConfigs alongside those entries.
Why does my LWC deployment say it cannot find an Apex action class?
Inspect the actual @salesforce/apex/... import in the JavaScript resource. Reported cases involved a class that existed only in the Dev Hub or was omitted from a component-only deployment. The class must be available in the destination org for those cases.
Does "No base file for markup" mean another component references my LWC?
Not necessarily. Reports associated this error with component filename and directory-name mismatches, path case mismatches, and an HTML-only directory missing JavaScript and configuration files.
Should targetConfigs and ai be base64 text in my .js-meta.xml file?
No. Although Metadata API represents these fields as base64Binary, declarative configuration uses nested XML for targetConfigs and ai. That API field type should not be confused with the on-disk configuration format.