wc-compiler 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -43
- package/dist/wcc.dist.js +14121 -0
- package/package.json +15 -4
- package/src/dom-shim.js +15 -10
- package/src/wcc.js +24 -23
package/README.md
CHANGED
|
@@ -1,44 +1,17 @@
|
|
|
1
|
-
# wcc
|
|
2
|
-
|
|
3
1
|
<img src="https://merry-caramel-524e61.netlify.app/assets/wcc-logo.png" width="30%"/>
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
**Web Components Compiler (WCC)** is a NodeJS package designed to make server-side rendering (SSR) of native Web Components easier. It can render (within reason 😅) your Web Component into static HTML leveraging [Declarative Shadow DOM](https://web.dev/declarative-shadow-dom/).
|
|
10
|
-
|
|
11
|
-
It is not a static site generator or framework. It is focused on producing raw HTML from Web Components with the intent of being easily _integrated_ into a site generator or framework.
|
|
12
|
-
|
|
13
|
-
> _The original motivation for this project was to create a [purpose built, lighter weight alternative to puppeteer for SSR of native `HTMLElement` based Web Components](https://github.com/ProjectEvergreen/greenwood/issues/935) for the project [**Greenwood**](https://www.greenwoodjs.io/)._
|
|
14
|
-
|
|
15
|
-
In addition, WCC hopes to provide a surface area to explore patterns around [streaming](https://github.com/ProjectEvergreen/wcc/issues/5) and serverless rendering, as well as acting as a test bed for the [Web Components Community Groups](https://github.com/webcomponents-cg) discussions around community protocols, like [hydration](https://github.com/ProjectEvergreen/wcc/issues/3).
|
|
16
|
-
|
|
17
|
-
## Key Features
|
|
3
|
+
# Web Components Compiler (WCC)
|
|
18
4
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- `innerHTML`
|
|
24
|
-
- `[get|set|has]Attribute`
|
|
25
|
-
1. Recursive rendering of nested custom elements
|
|
26
|
-
1. Optional Declarative Shadow DOM (for producing purely content driven static pages)
|
|
27
|
-
1. Metadata and runtime hints to support progressive hydration and lazy loading strategies
|
|
5
|
+
[](https://app.netlify.com/sites/merry-caramel-524e61/deploys)
|
|
6
|
+
[](https://github.com/ProjectEvergreen/wcc/tags)
|
|
7
|
+

|
|
8
|
+
[](https://raw.githubusercontent.com/ProjectEvergreen/wcc/master/LICENSE.md)
|
|
28
9
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
**wcc** can be installed from npm.
|
|
32
|
-
|
|
33
|
-
```shell
|
|
34
|
-
$ npm install wc-compiler --save-dev
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Usage
|
|
10
|
+
> _Experimental Web Components compiler. It's Web Components all the way down!_ 🐢
|
|
38
11
|
|
|
39
|
-
|
|
12
|
+
## How It Works
|
|
40
13
|
|
|
41
|
-
1.
|
|
14
|
+
1. Write a Web Component
|
|
42
15
|
```js
|
|
43
16
|
const template = document.createElement('template');
|
|
44
17
|
|
|
@@ -68,17 +41,13 @@ WCC exposes a few utilities to render your Web Components. Below is one example
|
|
|
68
41
|
|
|
69
42
|
customElements.define('wcc-footer', Footer);
|
|
70
43
|
```
|
|
71
|
-
|
|
72
|
-
1. Using NodeJS, create a file that imports `renderToString` and provide it the path to your web component
|
|
44
|
+
1. Run it through the compiler
|
|
73
45
|
```js
|
|
74
46
|
import { renderToString } from 'wc-compiler';
|
|
75
47
|
|
|
76
|
-
const { html } = await renderToString(new URL('./path/to/
|
|
77
|
-
|
|
78
|
-
console.debug({ html })
|
|
48
|
+
const { html } = await renderToString(new URL('./path/to/component.js', import.meta.url));
|
|
79
49
|
```
|
|
80
|
-
|
|
81
|
-
1. You will get the following HTML output that can be used in conjunction with your preferred site framework or templating solution.
|
|
50
|
+
1. Get HTML!
|
|
82
51
|
```html
|
|
83
52
|
<wcc-footer>
|
|
84
53
|
<template shadowroot="open">
|
|
@@ -96,5 +65,27 @@ WCC exposes a few utilities to render your Web Components. Below is one example
|
|
|
96
65
|
</wcc-footer>
|
|
97
66
|
```
|
|
98
67
|
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
**WCC** runs on NodeJS and can be installed from npm.
|
|
71
|
+
|
|
72
|
+
```shell
|
|
73
|
+
$ npm install wc-compiler --save-dev
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### CommonJS
|
|
77
|
+
|
|
78
|
+
If you need CommonJS support, a separate pre-bundled (with Rollup) distribution of **WCC** is available at _dist/wcc.dist.js_. Example:
|
|
79
|
+
```js
|
|
80
|
+
const { renderToString } = require('wc-compiler/dist/wcc.dist');
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
See our [website](https://merry-caramel-524e61.netlify.app/) for API docs and examples.
|
|
86
|
+
|
|
87
|
+
## Motivation
|
|
88
|
+
|
|
89
|
+
**WCC** is not a static site generator, framework or bundler. It is focused on producing raw HTML from Web Components with the intent of being easily integrated into a site generator or framework, like [**Greenwood**](https://github.com/ProjectEvergreen/greenwood/), the original motivation for creating [this project](https://github.com/ProjectEvergreen/greenwood/issues/935).
|
|
99
90
|
|
|
100
|
-
|
|
91
|
+
In addition, **WCC** hopes to provide a surface area to explore patterns around [streaming](https://github.com/ProjectEvergreen/wcc/issues/5) and serverless rendering, as well as acting as a test bed for the [Web Components Community Groups](https://github.com/webcomponents-cg) discussions around community protocols, like [hydration](https://github.com/ProjectEvergreen/wcc/issues/3).
|