bundleWorkerEntry() — vite Function Reference
Architecture documentation for the bundleWorkerEntry() function in worker.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 75aa4483_7f33_5bdd_19ac_866cac2679e4["bundleWorkerEntry()"] 971bf58d_477c_c4d8_0c3b_735e572044c4["worker.ts"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|defined in| 971bf58d_477c_c4d8_0c3b_735e572044c4 2263fc73_3545_6a6d_f020_363141e760f3["workerFileToUrl()"] 2263fc73_3545_6a6d_f020_363141e760f3 -->|calls| 75aa4483_7f33_5bdd_19ac_866cac2679e4 1a156a4f_5015_f60f_3a54_6eb2168861ca["webWorkerPlugin()"] 1a156a4f_5015_f60f_3a54_6eb2168861ca -->|calls| 75aa4483_7f33_5bdd_19ac_866cac2679e4 10b9dea8_362c_1af2_93be_afa4dd9aed9e["cleanUrl()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| 10b9dea8_362c_1af2_93be_afa4dd9aed9e 51afdf58_3045_64b1_cf5b_929b1091e877["get()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| 51afdf58_3045_64b1_cf5b_929b1091e877 3a996af5_4903_3cfe_6bc5_bcf4f52114c9["removeBundleIfInvalidated()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| 3a996af5_4903_3cfe_6bc5_bcf4f52114c9 4676ace1_9b6a_404e_362a_fd5188f91be6["getWorkerBundle()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| 4676ace1_9b6a_404e_362a_fd5188f91be6 0850ad90_f980_60a3_ab1f_b17433109b74["prettifyUrl()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| 0850ad90_f980_60a3_ab1f_b17433109b74 2b805bd3_afe5_06fa_d723_ae5cd9934c6e["init()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| 2b805bd3_afe5_06fa_d723_ae5cd9934c6e d7a9e9fe_edc0_c70e_690b_4591b789faca["injectEnvironmentToHooks()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| d7a9e9fe_edc0_c70e_690b_4591b789faca 5f780e97_091a_dfa9_1506_327f54d41dca["onRollupLog()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| 5f780e97_091a_dfa9_1506_327f54d41dca a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| a4adb1a7_cf54_091f_eb63_8217e684a8e1 0643e557_6a99_c2f8_645a_bc30c5eef1cb["saveWorkerBundle()"] 75aa4483_7f33_5bdd_19ac_866cac2679e4 -->|calls| 0643e557_6a99_c2f8_645a_bc30c5eef1cb style 75aa4483_7f33_5bdd_19ac_866cac2679e4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/plugins/worker.ts lines 162–292
async function bundleWorkerEntry(
config: ResolvedConfig,
id: string,
): Promise<WorkerBundle> {
const input = cleanUrl(id)
const workerOutput = workerOutputCaches.get(config.mainConfig || config)!
workerOutput.removeBundleIfInvalidated(input)
const bundleInfo = workerOutput.getWorkerBundle(input)
if (bundleInfo) {
return bundleInfo
}
const newBundleChain = [...config.bundleChain, input]
if (config.bundleChain.includes(input)) {
throw new Error(
'Circular worker imports detected. Vite does not support it. ' +
`Import chain: ${newBundleChain.map((id) => prettifyUrl(id, config.root)).join(' -> ')}`,
)
}
// bundle the file as entry to support imports
const { rolldown } = await import('rolldown')
const { plugins, rollupOptions, format } = config.worker
const workerConfig = await plugins(newBundleChain)
const workerEnvironment = new BuildEnvironment('client', workerConfig) // TODO: should this be 'worker'?
await workerEnvironment.init()
const chunkMetadataMap = new ChunkMetadataMap()
const bundle = await rolldown({
...rollupOptions,
input,
plugins: workerEnvironment.plugins.map((p) =>
injectEnvironmentToHooks(workerEnvironment, chunkMetadataMap, p),
),
onLog(level, log) {
onRollupLog(level, log, workerEnvironment)
},
// TODO: remove this and enable rolldown's CSS support later
moduleTypes: {
'.css': 'js',
...rollupOptions.moduleTypes,
},
preserveEntrySignatures: false,
})
let result: RolldownOutput
let watchedFiles: string[] | undefined
try {
const workerOutputConfig = config.worker.rollupOptions.output
const workerConfig = workerOutputConfig
? Array.isArray(workerOutputConfig)
? workerOutputConfig[0] || {}
: workerOutputConfig
: {}
result = await bundle.generate({
entryFileNames: path.posix.join(
config.build.assetsDir,
'[name]-[hash].js',
),
chunkFileNames: path.posix.join(
config.build.assetsDir,
'[name]-[hash].js',
),
assetFileNames: path.posix.join(
config.build.assetsDir,
'[name]-[hash].[ext]',
),
minify:
config.build.minify === 'oxc'
? true
: config.build.minify === false
? 'dce-only'
: undefined,
...workerConfig,
format,
sourcemap: config.build.sourcemap,
})
watchedFiles = (await bundle.watchFiles).map((f) => normalizePath(f))
} catch (e) {
// adjust rollup format error
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does bundleWorkerEntry() do?
bundleWorkerEntry() is a function in the vite codebase, defined in packages/vite/src/node/plugins/worker.ts.
Where is bundleWorkerEntry() defined?
bundleWorkerEntry() is defined in packages/vite/src/node/plugins/worker.ts at line 162.
What does bundleWorkerEntry() call?
bundleWorkerEntry() calls 10 function(s): cleanUrl, get, getWorkerBundle, init, injectEnvironmentToHooks, normalizePath, onRollupLog, prettifyUrl, and 2 more.
What calls bundleWorkerEntry()?
bundleWorkerEntry() is called by 2 function(s): webWorkerPlugin, workerFileToUrl.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free