makeStylWorker() — vite Function Reference
Architecture documentation for the makeStylWorker() function in css.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD e785fd68_f38b_c6ee_f2fa_64c4d896543f["makeStylWorker()"] c3eb47df_971b_0616_6c9f_29b3ded72224["css.ts"] e785fd68_f38b_c6ee_f2fa_64c4d896543f -->|defined in| c3eb47df_971b_0616_6c9f_29b3ded72224 158d0e42_28ce_8bd3_13df_1f08b6dbf23f["stylProcessor()"] 158d0e42_28ce_8bd3_13df_1f08b6dbf23f -->|calls| e785fd68_f38b_c6ee_f2fa_64c4d896543f style e785fd68_f38b_c6ee_f2fa_64c4d896543f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/plugins/css.ts lines 2962–3019
const makeStylWorker = (maxWorkers: number | undefined) => {
const worker = new WorkerWithFallback(
() => {
return async (
stylusPath: string,
content: string,
root: string,
// additionalData can a function that is not cloneable but it won't be used
options: StylusStylePreprocessorInternalOptions & {
additionalData: undefined
},
) => {
const stylus: typeof Stylus = (await import(stylusPath)).default
const ref = stylus(content, {
// support @import from node dependencies by default
paths: ['node_modules'],
...options,
})
if (options.define) {
for (const key in options.define) {
ref.define(key, options.define[key])
}
}
if (options.enableSourcemap) {
ref.set('sourcemap', {
comment: false,
inline: false,
basePath: root,
})
}
return {
code: ref.render(),
// @ts-expect-error sourcemap exists
map: ref.sourcemap as ExistingRawSourceMap | undefined,
deps: ref.deps(),
}
}
},
{
shouldUseFake(_stylusPath, _content, _root, options) {
// define can include functions and those are not serializable
// Evaluator is always a function
// in those cases, fallback to running in main thread
return !!(
(options.define &&
Object.values(options.define).some(
(d) => typeof d === 'function',
)) ||
options.Evaluator
)
},
max: maxWorkers,
},
)
return worker
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does makeStylWorker() do?
makeStylWorker() is a function in the vite codebase, defined in packages/vite/src/node/plugins/css.ts.
Where is makeStylWorker() defined?
makeStylWorker() is defined in packages/vite/src/node/plugins/css.ts at line 2962.
What calls makeStylWorker()?
makeStylWorker() is called by 1 function(s): stylProcessor.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free