Skip to content

Commit 5caff7d

Browse files
committed
add build + compat notes
1 parent 5b4c3db commit 5caff7d

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
.DS_Store
3+
dist

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,28 @@
44
55
## Compatibility
66

7-
Requires [native ES2015 class support](https://caniuse.com/#feat=es6-class). IE11 and below are not supported.
7+
**[Requires ES2015 classes](https://caniuse.com/es6-class). IE11 and below not supported.**
8+
9+
- **If targeting browsers that natively supports ES2015, but not native Web Components:**
10+
11+
You will also need the [Shady DOM + Custom Elements polyfill](https://github.com/webcomponents/webcomponentsjs/blob/master/webcomponents-sd-ce.js).
12+
13+
See caniuse for support on [Custom Elements v1](https://caniuse.com/#feat=custom-elementsv1) and [Shadow DOM v1](https://caniuse.com/#feat=shadowdomv1).
14+
15+
- **Note on CSS Encapsulation When Using the Shady DOM polyfill**
16+
17+
It's recommended to use [CSS Modules](https://vue-loader.vuejs.org/en/features/css-modules.html) instead of `<style scoped>` in your `*.vue` files if you intend to use the Shady DOM polyfill, because it does not offer real style encapsulation like Shadow DOM does, so external stylesheets may affect your components if not using hashed class names.
18+
19+
- **If targeting browsers that does not support ES2015:**
20+
21+
You might want to reconsider since you'll be better off not using Web Components in this case.
822

923
## Usage
1024

25+
- **`dist/vue-wc-wrapper.js`**: This file is in ES modules format. It's the default export for bundlers, and can be used in browsers with `<script type="module">`.
26+
27+
- **`dist/vue-wc-wrapper.global.js`**: This is for old school `<script>` includes in browsers that do not support `<script type="module">` yet (exposes `wrapVueWebComponent` global).
28+
1129
``` js
1230
import Vue from 'vue'
1331
import wrap from '@vue/web-component-wrapper'

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
"name": "@vue/web-component-wrapper",
33
"version": "1.0.0",
44
"description": "wrap a vue component as a web component.",
5-
"main": "src/index.js",
5+
"main": "dist/vue-wc-wrapper.js",
6+
"unpkg": "dist/vue-wc-wrapper.global.js",
67
"scripts": {
78
"test": "jest",
8-
"lint": "eslint src"
9+
"lint": "eslint src",
10+
"build": "rollup -c",
11+
"pretest": "yarn build"
912
},
1013
"repository": {
1114
"type": "git",
@@ -28,6 +31,7 @@
2831
"jest": "^22.1.4",
2932
"lint-staged": "^6.1.0",
3033
"puppeteer": "^1.0.0",
34+
"rollup": "^0.55.3",
3135
"vue": "^2.5.13",
3236
"yorkie": "^1.0.3"
3337
},

rollup.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default {
2+
input: 'src/index.js',
3+
output: [
4+
{
5+
format: 'es',
6+
file: 'dist/vue-wc-wrapper.js'
7+
},
8+
{
9+
format: 'iife',
10+
name: 'wrapVueWebComponent',
11+
file: 'dist/vue-wc-wrapper.umd.js'
12+
}
13+
]
14+
}

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,6 +3008,10 @@ rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:
30083008
dependencies:
30093009
glob "^7.0.5"
30103010

3011+
rollup@^0.55.3:
3012+
version "0.55.3"
3013+
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.55.3.tgz#0af082a766d51c3058430c8372442ff5207d8736"
3014+
30113015
run-async@^2.2.0:
30123016
version "2.3.0"
30133017
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0"

0 commit comments

Comments
 (0)