@netvlies/wsc-js-moduleloader
Version:
module loader to be imported in skeletons
41 lines (26 loc) • 899 B
Markdown
# wsc-moduleloader
The purpose of this module is to abstract the module loader and base module components so they can be implemented independently.
## Setup
The module can be installed by running:
`npm i -D @netvlies/wsc-js-moduleloader`
## Usage
Create custom modules in your HTML using a web component (default: `<nvs-module>`). It is best-practice to prefix them with `nvs` for readability and consistency throughout our projects.
```html
<nvs-nav>
<ul>...</ul>
</nvs-nav>
```
Loop through your custom webcomponents in your source code using this setup:
```js
import Nav from './modules/Nav';
const webComponents = [Nav];
for (const { element, module } of webComponents) {
customElements.define(element, module);
}
```
Create the modules using the default framework in the [Base module] which can be found in the `lib` folder.
```html
<nvs-nav>
<ul>...</ul>
</nvs-nav>
```