|
@ -106,7 +106,7 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) { |
|
|
// slightly differently.
|
|
|
// slightly differently.
|
|
|
let runner // lazy creation so that errors can be caught by user
|
|
|
let runner // lazy creation so that errors can be caught by user
|
|
|
let initialContext |
|
|
let initialContext |
|
|
return (userContext = {}) => new Promise((resolve, reject) => { |
|
|
return (userContext = {}) => new Promise(resolve => { |
|
|
if (!runner) { |
|
|
if (!runner) { |
|
|
const sandbox = runInNewContext === 'once' |
|
|
const sandbox = runInNewContext === 'once' |
|
|
? createSandbox() |
|
|
? createSandbox() |
|
@ -126,27 +126,25 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
userContext._registeredComponents = new Set() |
|
|
userContext._registeredComponents = new Set() |
|
|
|
|
|
|
|
|
// vue-style-loader styles imported outside of component lifecycle hooks
|
|
|
// vue-style-loader styles imported outside of component lifecycle hooks
|
|
|
if (initialContext._styles) { |
|
|
if (initialContext._styles) { |
|
|
userContext._styles = deepClone(initialContext._styles) |
|
|
userContext._styles = deepClone(initialContext._styles) |
|
|
} |
|
|
// #6353 ensure "styles" is exposed even if no styles are injected
|
|
|
// #6353 after the app is resolved, if the userContext doesn't have a
|
|
|
// in component lifecycles.
|
|
|
// styles property, it means the app doesn't have any lifecycle-injected
|
|
|
// the renderStyles fn is exposed by vue-style-loader >= 3.0.3
|
|
|
// styles, so vue-style-loader never defined the styles getter.
|
|
|
const renderStyles = initialContext._renderStyles |
|
|
// just expose the same styles from the initialContext.
|
|
|
if (renderStyles) { |
|
|
const exposeStylesAndResolve = app => { |
|
|
Object.defineProperty(userContext, 'styles', { |
|
|
if (!userContext.hasOwnProperty('styles')) { |
|
|
enumerable: true, |
|
|
userContext.styles = initialContext.styles |
|
|
get () { |
|
|
|
|
|
return renderStyles(userContext._styles) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
resolve(app) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const res = runner(userContext) |
|
|
resolve(runner(userContext)) |
|
|
if (typeof res.then === 'function') { |
|
|
|
|
|
res.then(exposeStylesAndResolve).catch(reject) |
|
|
|
|
|
} else { |
|
|
|
|
|
exposeStylesAndResolve(res) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|