Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[dreamOlé 2023] Build your apps everywhere with...

[dreamOlé 2023] Build your apps everywhere with LWC Open Source

Fabien Taillon

March 31, 2023
Tweet

More Decks by Fabien Taillon

Other Decks in Programming

Transcript

  1. Fabien Taillon - 8x Salesforce MVP - CTO at Texeï

    - Paris Developer Group leader - French Touch Dreamin team - Serial speaker - Not so serial blogger @FabienTaillon https://texei.com/blog
  2. • What’s Open Sourced at Salesforce • What’s available as

    a public package • What can be done • Let’s build something with Lightning Web Runtime • Demo • Differences between OSS & Platform Agenda
  3. A whole site dedicated to OSS (open source software): https://opensource.salesforce.com

    Some OSS Projects: • Lightning Web Components • Salesforce Extensions for VS Code • Salesforce Lightning Design System • oclif • … Not something new, Aura was already open source. What’s Open Sourced at Salesforce
  4. Some other projects are not open sourced, but available as

    packages (npm) for us to use: • Lightning Web Runtime • Lightning Base Components • … What’s available as a public package
  5. Benefit from all publicly available resources to build your own

    application locally, hosted wherever you want: • Lightning Web Runtime • Lightning Web Components • Salesforce Lightning Design System • Lightning Base Components What can be done
  6. Benefit from all publicly available resources to build your own

    application locally, hosted wherever you want: • Lightning Web Runtime • Lightning Web Components • Salesforce Lightning Design System • Lightning Base Components • Custom @wire api What can be done
  7. Benefit from all publicly available resources to build your own

    application locally, hosted wherever you want: • Lightning Web Runtime • Lightning Web Components • Salesforce Lightning Design System • Lightning Base Components • Custom @wire api • Use Lightning Navigation Service What can be done
  8. Benefit from all publicly available resources to build your own

    application locally, hosted wherever you want: • Lightning Web Runtime • Lightning Web Components • Salesforce Lightning Design System • Lightning Base Components • Custom @wire api • Use Lightning Navigation Service • Use OSS first/only features (Light DOM, dynamic component creation) What can be done
  9. Benefit from all publicly available resources to build your own

    application locally, hosted wherever you want: • Lightning Web Runtime • Lightning Web Components • Salesforce Lightning Design System • Lightning Base Components • Custom @wire api • Use Lightning Navigation Service • Use OSS first/only features (Light DOM, dynamic component creation) • Any tool of your choice (Rollup, webpack, TypeScript…) What can be done
  10. • LWR is a runtime built with performance in mind

    • Loads modules/services, like routing • Used by the latest Experience Cloud templates • Configurable via lwr.config.json Easy to start with: npm init lwr https://developer.salesforce.com/docs/platform/lwr/overview Let’s build something with Lightning Web Runtime
  11. • Create src/layouts/main.html ◦ see template here: https://developer.salesforce.com/docs/platform/lwr/ guide/lwr-slds.html •

    Add stylesheet link https://developer.salesforce.com/docs/platform/lwr/guid e/lwr-slds.html Add SLDS
  12. Basically just an ES6 module with a few functions: •

    constructor • connect • disconnect • Update https://lwc.dev/guide/wire_adapter Custom @wire
  13. • Custom images/assets vs static resources (different import) ◦ OSS:

    just add files to src/assets folder ◦ Platform: import myResource from '@salesforce/resourceUrl/resourceReference'; • Custom @wire → not allowed on Platform, replaced by Apex Class ◦ OSS: import { getUser } from 'c/usersWireApi'; ◦ Platform: import getUser from '@salesforce/apex/Namespace.UsersWireApi.getUser'; Differences between OSS & Platform
  14. • Navigation page names ◦ OSS: whatever name you would

    like (eg. “namedPage”) ◦ Platform: page names expected by Salesforce (ex: comm__namedPage) • Metadata file (myComponent.js-meta.xml) ◦ OSS: No need, but won’t complain if the file is there ◦ Platform: expected by Salesforce, Differences between OSS & Platform
  15. • Presentational components • No Salesforce only import • Navigation

    is OK • Was designed to work everywhere from the start ◦ Use Salesforce expected page names • Won’t fit for all components Components suited to use everywhere
  16. LWC: • https://lwc.dev • https://github.com/salesforce/lwc LWR: • https://developer.salesforce.com/docs/platform/lwr/over view SLDS:

    • https://www.lightningdesignsystem.com • https://github.com/salesforce-ux/design-system Resources