# html-scoped-component-importer

> Async html scoped components dispatcher

Latest version **1.2.0** (published 2021-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-scoped-component-importer
pnpm add html-scoped-component-importer
yarn add html-scoped-component-importer
bun add html-scoped-component-importer
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2021-03-07 |
| First published | 2020-01-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 399 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Felice Caricati |
| Maintainers | felice.c |

## Links

- npm: https://www.npmjs.com/package/html-scoped-component-importer
- Repository: https://github.com/FeliceC/html-scoped-component-importer
- Homepage: https://github.com/FeliceC/html-scoped-component-importer#readme
- Issues: https://github.com/FeliceC/html-scoped-component-importer/issues
- npm.io page: https://npm.io/package/html-scoped-component-importer

## Dependencies (3)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [http-server](https://npm.io/package/http-server.md) ^0.12.1
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.8.3

## Recent versions

- 1.2.0 (latest) — 2021-03-07
- 1.1.6 — 2021-02-19
- 1.1.4 — 2021-02-12
- 1.1.3 — 2020-04-08
- 1.1.2 — 2020-03-25
- 1.1.1 — 2020-03-13
- 1.1.0 — 2020-01-28
- 1.0.4 — 2020-01-28
- 1.0.3 — 2020-01-23
- 1.0.2 — 2020-01-20
- 1.0.1 — 2020-01-20
- 1.0.0 — 2020-01-20

## README

[![Build Status](https://travis-ci.org/FeliceC/html-scoped-component-importer.svg?branch=master)](https://travis-ci.org/FeliceC/html-scoped-component-importer)

#html-scoped-component-importer

This is a simple tool to let you create and dynamically import scoped components. All you need is a html element with the *data-component* attribute and it 
will be imported and initialized.

# Index

- [Installation](#installation)
- [Usage](#usage)
- [Example](/example)
- [License](/LICENSE)

# Installation

**yarn**

```sh
yarn add html-scoped-component-importer
```

**npm**

```sh
npm install --save html-scoped-component-importer
```

# Usage

## webpack config
```js
module.exports = {
  ...
  resolve: {
    alias: {
      COMPONENTS: path.resolve(__dirname, '{your components folder}'),
    }
  }
  ...
}
```

## main.js
```js
import { ComponentDispatcher } from 'html-scoped-component-importer';

const compDispatcher = new ComponentDispatcher();
compDispatcher.createAsyncComponents();
```

## ExampleComponent.js
```js
export default class ExampleComponent {
  constructor(element) {
    super(element);
    element.innerHTML = element.dataset.component;
  }
}
```

```html
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Title</title>
  <script async="async" defer="defer" src="main.js"></script>
</head>

<body>
  <div data-component="ExampleComponent"></div>
</body>
```

---
_Source: https://npm.io/package/html-scoped-component-importer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
