build: add vue 2.x compat package

This commit is contained in:
Evan You 2018-09-19 21:52:24 -04:00
parent bc8b1678f4
commit 360ab65117
5 changed files with 70 additions and 0 deletions

3
packages/vue/.npmignore Normal file
View File

@ -0,0 +1,3 @@
__tests__/
__mocks__/
dist/packages

3
packages/vue/README.md Normal file
View File

@ -0,0 +1,3 @@
# vue
The 2.x compatibility build.

7
packages/vue/index.js Normal file
View File

@ -0,0 +1,7 @@
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/vue.cjs.prod.js')
} else {
module.exports = require('./dist/vue.cjs.js')
}

30
packages/vue/package.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "vue",
"version": "3.0.0-alpha.1",
"description": "vue",
"main": "index.js",
"module": "dist/vue.esm-bundler.js",
"typings": "dist/index.d.ts",
"unpkg": "dist/vue.global.js",
"buildOptions": {
"name": "Vue",
"compat": true,
"formats": ["esm", "cjs", "global", "esm-browser"]
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vue.git"
},
"keywords": [
"vue"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/vue/issues"
},
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue#readme",
"dependencies": {
"@vue/renderer-dom": "3.0.0-alpha.1"
}
}

27
packages/vue/src/index.ts Normal file
View File

@ -0,0 +1,27 @@
import { h, render, ComponentOptions } from '@vue/renderer-dom'
function Vue(options: ComponentOptions & { el: any }) {
const { el, render: r } = options
if (r) {
options.render = function(props, slots) {
return r.call(this, h, props, slots)
}
}
function mount(el: any) {
const dom = document.querySelector(el)
render(h(options), dom)
return (dom as any).vnode.children.$proxy
}
if (el) {
return mount(el)
} else {
return {
$mount: mount
}
}
}
export default Vue