Code Monkey home page Code Monkey logo

lwrjs-lwc-module-provider's Introduction

@lukethacoder/lwrjs-lwc-module-provider

⚡ An opinionated edit to the @lwrjs/lwc-module-provider package to add support for namespaces and multi directory modules (via @lukethacoder/lwc-module-resolver)

Install

pnpm add @lukethacoder/lwrjs-lwc-module-provider

Edit your lwr.config.json file to include the module.

{
  "lwc": {
    "modules": [],
  },
  "moduleProviders": [
    "@lwrjs/label-module-provider",
    "@lwrjs/app-service/moduleProvider",
    "@lukethacoder/lwrjs-lwc-module-provider",
    "@lwrjs/npm-module-provider"
  ],
  "routes": []
}

Custom Namespace Directories

The heavy lifting of the enhancements come from the @lukethacoder/lwc-module-resolver package. Below is a snippet of the docs from that package.

Instead of assuming the namespace based on the folder structure, you can declaratively set namespaces to directories. Automatic namespacing is still enabled.

The primary driver for this is the on platform folder structure conflicting with the standard open source folder structure.

Multiple directory per namespace is also supported. This is great for package developers who wish to break up their code into smaller packages but still have the benefits of a local dev server.

{
  "modules": [
    {
      "dir": "src/modules"
    },
    { 
      "dir": "force-app/main/default/lwc",
      "namespace": "c" 
    }
  ]
}

This example shows how you can assign the c namespace to the default salesforce LWC folder, whilst still keeping the standard config for folder based namespacing.

Multi Directory Namespacing

Multiple directory per namespace has also been added. This is great for package developers who wish to break up their code into smaller packages but still want to have the benefits of a local dev server.

{
  "modules": [
    {
      "dir": "src/modules"
    },
    { 
      "dir": "force-app/main/default/lwc",
      "namespace": "c" 
    },
    {
      "dirs": [
        "force-app/ui-account-flow/default/lwc",
        "force-app/ui-shared/default/lwc"
      ],
      "namespace": "ui"
    }
  ]
}

This example shows how you can assign the ui namespace to multiple source folders, whilst still keeping the standard config for folder based namespacing.

NOTE: This package aims to open up current imitations enforced by open source LWC and on-platform Salesforce development. This is done purely to make your life as a developer easier and is not intended to be used as a part of a production build. These enhancements may allow you to do things that will NOT work on-platform.

lwrjs-lwc-module-provider's People

Contributors

lukethacoder avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.