mirror of
https://gitee.com/vuejs/vue.git
synced 2024-11-30 02:57:43 +08:00
decouple renderer logic and web platform
This commit is contained in:
parent
ae7054f4e9
commit
f629b345c4
@ -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')
|
||||
}
|
||||
|
@ -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'
|
||||
}
|
||||
])
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
})
|
||||
|
@ -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)
|
Loading…
Reference in New Issue
Block a user