decouple renderer logic and web platform

This commit is contained in:
Evan You 2016-04-25 00:06:33 -04:00
parent ae7054f4e9
commit f629b345c4
4 changed files with 30 additions and 20 deletions

View File

@ -5,5 +5,6 @@ module.exports = {
compiler: path.resolve(__dirname, '../src/compiler'),
core: path.resolve(__dirname, '../src/core'),
shared: path.resolve(__dirname, '../src/shared'),
web: path.resolve(__dirname, '../src/platforms/web')
web: path.resolve(__dirname, '../src/platforms/web'),
server: path.resolve(__dirname, '../src/server')
}

View File

@ -63,6 +63,12 @@ build([
format: 'cjs',
external: ['entities'],
out: 'dist/compiler.common.js'
},
// Web server renderer
{
entry: 'src/entries/web-server-renderer.js',
format: 'cjs',
out: 'dist/server-renderer.js'
}
])

View File

@ -1,3 +1,18 @@
import { createComponentRenderer } from 'web/server/create-renderer'
import { createRenderer } from 'server/create-renderer'
import attrs from 'web/server/modules/attrs'
import klass from 'web/server/modules/class'
import style from 'web/server/modules/style'
import show from 'web/server/directives/show'
import { isUnaryTag } from 'web/util/index'
export default createComponentRenderer()
export default createRenderer({
isUnaryTag,
modules: {
attrs,
style,
class: klass
},
directives: {
show
}
})

View File

@ -1,20 +1,8 @@
import renderAttrs from './modules/attrs'
import renderClass from './modules/class'
import renderStyle from './modules/style'
import show from './directives/show'
import { isUnaryTag } from 'web/util/index'
export function createComponentRenderer (options = {}) {
const modules = Object.assign({
attrs: renderAttrs,
style: renderStyle,
class: renderClass
}, options.modules)
const directives = Object.assign({
show
}, options.directives)
export function createRenderer ({
modules = {},
directives = {},
isUnaryTag = (() => false)
} = {}) {
function renderComponent (component) {
component.$mount()
return renderElement(component._vnode)