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 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
- > _Experimental Web Components compiler. It's Web Components all the way down!_ 🐢
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
- 1. Supports the following `HTMLElement` lifecycles and methods on the server side
20
- - `constructor`
21
- - `connectedCallback`
22
- - `attachShadow`
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
+ [![Netlify Status](https://api.netlify.com/api/v1/badges/e718eac2-b3bc-4986-8569-49706a430beb/deploy-status)](https://app.netlify.com/sites/merry-caramel-524e61/deploys)
6
+ [![GitHub release](https://img.shields.io/github/tag/ProjectEvergreen/wcc.svg)](https://github.com/ProjectEvergreen/wcc/tags)
7
+ ![GitHub Actions status](https://github.com/ProjectEvergreen/wcc/workflows/Master%20Integration/badge.svg)
8
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/ProjectEvergreen/wcc/master/LICENSE.md)
28
9
 
29
- ## Installation
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
- WCC exposes a few utilities to render your Web Components. Below is one example, with [full docs and more examples](https://merry-caramel-524e61.netlify.app/) available on the website.
12
+ ## How It Works
40
13
 
41
- 1. Given a custom element like so:
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/footer.js', import.meta.url));
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
- > _**Make sure to test in Chrome, or other Declarative Shadow DOM compatible browser, otherwise you will need to include the [DSD polyfill](https://web.dev/declarative-shadow-dom/#polyfill).**_
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).