Lightning Web Component Bundle : jayakrishnasfdc

Lightning Web Component Bundle
by: jayakrishnasfdc
blow post content copied from  Jayakrishna Ganjikunta
click here to view original post


The same way how we have Aura Bundle in LWC implementation also we have Web component Bundle.

Component File Structure

  1. * HTML File (helloWorld.html)
  2. * JavaScript File (helloWorld.js)
  3. * Configuration File(helloWorld.js-meta.xml)
  4. CSS File (helloWorld.css)
  5. SVG Icon
  6. Extra JS File
  7. Component Test File

  NOTE: Files with * are mandatory.

HTML FILE:
The HTML file is enclosed within the <template> tags.  It contains the component HTML.

JAVASCRIPT FILE:
A sample javascript file is shown in the below image.

Metadata configuration file:
A sample metadata configuration file is shown in the below image.

We can also create a .css file for styling purpose as shown in the below image. We can also create svg file for purpose of displaying icon.

The folder and its files must follow these naming rules:

  • Must begin with a lowercase letter
  • Must contain only alphanumeric or underscore characters
  • Must be unique in the namespace
  • Should not contain whitespace
  • Should not end with an underscore
  • Should not contain two consecutive underscores
  • Should not contain a hypen (dash)
  • Use camel case (each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation) to name a component. e.g. helloWorld  
  • Camel case component folder names map to kebab-case in markup. e.g. <c-hello-world>  where c is the default namespace.   
  • The component bundle file structure is different for an Aura component and a Lightning Web Component. Here’s how the files map between the two types of component.
  • An HTML File, a JavaScript File & a Configuration File should be present in Lightning Web Component. Css File and Other JavaScript file can be optional.
  • Separate Controller, Helper & Renderer files in Aura Component is equivalent to one JavaScript file in LWC.
Resource Aura File Lightning Web Components File
Markup helloWorld.cmp helloWorld.html
Controller helloWorldController.js     helloWorld.js
Helper helloWorldHelper.js
Renderer helloWorldRenderer.js
CSS helloWorld.css helloWorld.css
Documentation helloWorld.auradoc Not currently available
Design helloWorld.design helloWorld.js-meta.xml
SVG helloWorld.svg Include in HTML file or upload as a static resource

Thanks


November 30, 2020 at 04:08PM
Click here for more details...

=============================
The original post is available in Jayakrishna Ganjikunta by jayakrishnasfdc
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce