createBundleRunner() — vue Function Reference
Architecture documentation for the createBundleRunner() function in create-bundle-runner.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD e142ddd7_db7e_6e31_6600_9ceabc3f3fa2["createBundleRunner()"] 5a1c51f2_4876_fec0_df27_1d6ef59f031a["create-bundle-runner.ts"] e142ddd7_db7e_6e31_6600_9ceabc3f3fa2 -->|defined in| 5a1c51f2_4876_fec0_df27_1d6ef59f031a 12e2c88e_c7c5_fea0_a285_dc96ab9156f5["createBundleRendererCreator()"] 12e2c88e_c7c5_fea0_a285_dc96ab9156f5 -->|calls| e142ddd7_db7e_6e31_6600_9ceabc3f3fa2 47147685_60c2_42a0_ee05_26d072a377c7["compileModule()"] e142ddd7_db7e_6e31_6600_9ceabc3f3fa2 -->|calls| 47147685_60c2_42a0_ee05_26d072a377c7 93174abd_a7b7_1b99_3ec7_e9f031db9e7c["createSandbox()"] e142ddd7_db7e_6e31_6600_9ceabc3f3fa2 -->|calls| 93174abd_a7b7_1b99_3ec7_e9f031db9e7c 0cdf1653_ed47_3425_f24e_b38c3fe18e96["deepClone()"] e142ddd7_db7e_6e31_6600_9ceabc3f3fa2 -->|calls| 0cdf1653_ed47_3425_f24e_b38c3fe18e96 style e142ddd7_db7e_6e31_6600_9ceabc3f3fa2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/server-renderer/src/bundle-renderer/create-bundle-runner.ts lines 93–158
export function createBundleRunner(entry, files, basedir, runInNewContext) {
const evaluate = compileModule(files, basedir, runInNewContext)
if (runInNewContext !== false && runInNewContext !== 'once') {
// new context mode: creates a fresh context and re-evaluate the bundle
// on each render. Ensures entire application state is fresh for each
// render, but incurs extra evaluation cost.
return (userContext = {}) =>
new Promise(resolve => {
// @ts-expect-error
userContext._registeredComponents = new Set()
const res = evaluate(entry, createSandbox(userContext))
resolve(typeof res === 'function' ? res(userContext) : res)
})
} else {
// direct mode: instead of re-evaluating the whole bundle on
// each render, it simply calls the exported function. This avoids the
// module evaluation costs but requires the source code to be structured
// slightly differently.
let runner // lazy creation so that errors can be caught by user
let initialContext
return (userContext = {}) =>
new Promise(resolve => {
if (!runner) {
const sandbox = runInNewContext === 'once' ? createSandbox() : global
// the initial context is only used for collecting possible non-component
// styles injected by vue-style-loader.
// @ts-expect-error
initialContext = sandbox.__VUE_SSR_CONTEXT__ = {}
runner = evaluate(entry, sandbox)
// On subsequent renders, __VUE_SSR_CONTEXT__ will not be available
// to prevent cross-request pollution.
// @ts-expect-error
delete sandbox.__VUE_SSR_CONTEXT__
if (typeof runner !== 'function') {
throw new Error(
'bundle export should be a function when using ' +
'{ runInNewContext: false }.'
)
}
}
// @ts-expect-error
userContext._registeredComponents = new Set()
// vue-style-loader styles imported outside of component lifecycle hooks
if (initialContext._styles) {
// @ts-expect-error
userContext._styles = deepClone(initialContext._styles)
// #6353 ensure "styles" is exposed even if no styles are injected
// in component lifecycles.
// the renderStyles fn is exposed by vue-style-loader >= 3.0.3
const renderStyles = initialContext._renderStyles
if (renderStyles) {
Object.defineProperty(userContext, 'styles', {
enumerable: true,
get() {
// @ts-expect-error
return renderStyles(userContext._styles)
}
})
}
}
resolve(runner(userContext))
})
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does createBundleRunner() do?
createBundleRunner() is a function in the vue codebase, defined in packages/server-renderer/src/bundle-renderer/create-bundle-runner.ts.
Where is createBundleRunner() defined?
createBundleRunner() is defined in packages/server-renderer/src/bundle-renderer/create-bundle-runner.ts at line 93.
What does createBundleRunner() call?
createBundleRunner() calls 3 function(s): compileModule, createSandbox, deepClone.
What calls createBundleRunner()?
createBundleRunner() is called by 1 function(s): createBundleRendererCreator.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free