@@ -43,18 +43,67 @@ solidify.
43
43
## Installing
44
44
45
45
``` sh
46
- npm install hd- html
46
+ npm install @polymer/ html-modules-toolkit
47
47
```
48
48
49
+ ## What is included
50
+
51
+ This project includes low-level, versatile string-to-string transforms that can
52
+ analyze a file in place, and produce the appropriate ES Module-compatible
53
+ output.
54
+
55
+ You can import these low-level transforms into your Node.js build pipeline or
56
+ dev server of choice:
57
+
58
+ ``` javascript
59
+ import {htmlModuleToJsModuleMap } from
60
+ ' @polymer/html-modules-toolkit/lib/html-module-transform' ;
61
+ import {transformSpecifiersInHtmlString ,transformSpecifiersInJsString } from
62
+ ' @polymer/html-modules-toolkit/lib/html-module-specifier-transform' ;
63
+ ```
64
+
65
+ This project also includes higher-level wrappers of the transform for different
66
+ practical use cases. The available wrappers include:
67
+
68
+ - ** Webpack plugin:**
69
+ ``` javascript
70
+ import {HtmlModulesPlugin } from
71
+ ' @polymer/html-modules-toolkit/lib/html-module-transform/webpack-plugin' ;
72
+ ```
73
+ - ** Gulp-compatible vinyl-fs transforms:**
74
+ ``` javascript
75
+ import {HtmlModuleTransform ,HtmlModuleSpecifiersTransform } from
76
+ ' @polymer/html-modules-toolkit/lib/vinyl-transform' ;
77
+ ```
78
+ - ** Express middleware:**
79
+ ``` javascript
80
+ import {htmlModulesMiddleware } from
81
+ ' @polymer/html-modules-toolkit/lib/express-middleware' ;
82
+ ```
83
+ - ** Koa middleware:**
84
+ ``` javascript
85
+ import {htmlModulesMiddleware } from
86
+ ' @polymer/html-modules-toolkit/lib/koa-middleware' ;
87
+ ```
88
+
89
+ ### Specifier transforms
90
+
91
+ If you look closely at the above import statements, you will notice that in some
92
+ cases there are separate transforms offered for converting specifiers. This
93
+ transform is offered separately because it is not always needed. For example, in
94
+ a dev server the server can control the ` Content-Type ` of the file being sent,
95
+ and can send ` text/javascript ` even if the file has a ` .html ` file extension.
96
+
49
97
## Usage examples
50
98
51
99
You can find some concrete usage examples in the
52
- [ ` test /` ] ( https://github.com/PolymerLabs/hd- html/tree/master/test ) directory
100
+ [ ` examples /` ] ( https://github.com/PolymerLabs/html-modules-toolkit /tree/master/examples ) directory
53
101
of this project. The examples include:
54
102
55
- - [ An Express dev server] ( https://github.com/PolymerLabs/hd-html/blob/master/test/serve-express.js )
56
- - [ A Koa dev server] ( https://github.com/PolymerLabs/hd-html/blob/master/test/serve-koa.js )
57
- - [ A vinyl-fs (Gulp) static build pipeline] ( https://github.com/PolymerLabs/hd-html/blob/master/test/build.js )
103
+ - [ An Express dev server] ( https://github.com/PolymerLabs/html-modules-toolkit/blob/master/examples/express )
104
+ - [ A Koa dev server] ( https://github.com/PolymerLabs/html-modules-toolkit/blob/master/examples/koa )
105
+ - [ A Gulp (vinyl-fs) build pipeline] ( https://github.com/PolymerLabs/html-modules-toolkit/blob/master/examples/gulp )
106
+ - [ A Webpack build pipeline] ( https://github.com/PolymerLabs/html-modules-toolkit/blob/master/examples/webpack )
58
107
59
108
Additionally, you can find a live example of the Koa middleware in action on
60
109
[ Glitch] ( https://glitch.com/edit/#!/html-modules ) .
0 commit comments