Skip to content

Commit

Permalink
fix ssr initial context style recording
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 25, 2017
1 parent 016920e commit 2a247fc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/server/bundle-renderer/create-bundle-runner.js
@@ -1,4 +1,4 @@
import { isObject } from 'shared/util'
import { isPlainObject } from 'shared/util'

const vm = require('vm')
const path = require('path')
Expand Down Expand Up @@ -73,7 +73,7 @@ function compileModule (files, basedir) {
}

function deepClone (val) {
if (isObject(val)) {
if (isPlainObject(val)) {
const res = {}
for (const key in val) {
res[key] = deepClone(val[key])
Expand Down Expand Up @@ -108,14 +108,13 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) {
const initialContext = {}
const sharedContext = createContext(initialContext)

// On subsequent renders, __VUE_SSR_CONTEXT__ will not be avaialbe
// to prevent cross-request pollution.
delete sharedContext.__VUE_SSR_CONTEXT__

let runner // lazy creation so that errors can be caught by user
return (userContext = {}) => new Promise(resolve => {
if (!runner) {
runner = evaluate(entry, sharedContext)
// On subsequent renders, __VUE_SSR_CONTEXT__ will not be avaialbe
// to prevent cross-request pollution.
delete sharedContext.__VUE_SSR_CONTEXT__
if (typeof runner !== 'function') {
throw new Error(
'bundle export should be a function when using ' +
Expand Down

0 comments on commit 2a247fc

Please sign in to comment.