parseWorkerOptions() — vite Function Reference
Architecture documentation for the parseWorkerOptions() function in workerImportMetaUrl.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 2bc39ad0_e74f_e4f8_2016_48276895bfca["parseWorkerOptions()"] f241296c_aba8_08ac_c4f9_aed85a9eb247["workerImportMetaUrl.ts"] 2bc39ad0_e74f_e4f8_2016_48276895bfca -->|defined in| f241296c_aba8_08ac_c4f9_aed85a9eb247 fcb9c288_b3dc_c5f2_7476_d243d97d0e75["getWorkerType()"] fcb9c288_b3dc_c5f2_7476_d243d97d0e75 -->|calls| 2bc39ad0_e74f_e4f8_2016_48276895bfca 1c99a215_ac45_d0f0_ba6d_8a18ab03dcc7["extractWorkerTypeFromAst()"] 2bc39ad0_e74f_e4f8_2016_48276895bfca -->|calls| 1c99a215_ac45_d0f0_ba6d_8a18ab03dcc7 f23f9ad3_5ac1_6998_4142_106a985db0b0["err()"] 2bc39ad0_e74f_e4f8_2016_48276895bfca -->|calls| f23f9ad3_5ac1_6998_4142_106a985db0b0 style 2bc39ad0_e74f_e4f8_2016_48276895bfca fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/plugins/workerImportMetaUrl.ts lines 96–132
async function parseWorkerOptions(
rawOpts: string,
optsStartIndex: number,
): Promise<WorkerOptions> {
let opts: WorkerOptions = {}
try {
opts = evalValue<WorkerOptions>(rawOpts)
} catch {
const optsNode = (
(await parseAstAsync(`(${rawOpts})`)).body[0] as ExpressionStatement
).expression
const type = extractWorkerTypeFromAst(optsNode, optsStartIndex)
if (type) {
return { type }
}
throw err(
'Vite is unable to parse the worker options as the value is not static. ' +
'To ignore this error, please use /* @vite-ignore */ in the worker options.',
optsStartIndex,
)
}
if (opts == null) {
return {}
}
if (typeof opts !== 'object') {
throw err(
`Expected worker options to be an object, got ${typeof opts}`,
optsStartIndex,
)
}
return opts
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does parseWorkerOptions() do?
parseWorkerOptions() is a function in the vite codebase, defined in packages/vite/src/node/plugins/workerImportMetaUrl.ts.
Where is parseWorkerOptions() defined?
parseWorkerOptions() is defined in packages/vite/src/node/plugins/workerImportMetaUrl.ts at line 96.
What does parseWorkerOptions() call?
parseWorkerOptions() calls 2 function(s): err, extractWorkerTypeFromAst.
What calls parseWorkerOptions()?
parseWorkerOptions() is called by 1 function(s): getWorkerType.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free