worker.ts — vite Source File
Architecture documentation for worker.ts, a typescript file in the vite codebase. 31 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR 971bf58d_477c_c4d8_0c3b_735e572044c4["worker.ts"] 7da774f9_eca5_d54e_6e01_6bee7d460a2b["config.ts"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 7da774f9_eca5_d54e_6e01_6bee7d460a2b eb5604c2_58e1_1c00_5a1a_5d97ea5236ad["ResolvedConfig"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> eb5604c2_58e1_1c00_5a1a_5d97ea5236ad 5abb8c87_ffcb_f2d4_7421_e36705d9e5c7["plugin.ts"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 5abb8c87_ffcb_f2d4_7421_e36705d9e5c7 dfa3f5a8_b519_cb65_4b7e_9d4824406fd4["perEnvironmentPlugin"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> dfa3f5a8_b519_cb65_4b7e_9d4824406fd4 545df65b_7f67_94d3_e2e8_a592d5e64b8f["constants.ts"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 545df65b_7f67_94d3_e2e8_a592d5e64b8f 031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 031bc221_67a8_c579_f2bf_bb30a08beeb2 41d0f7a0_ed36_9f0f_d0d6_f403e4f50763["encodeURIPath"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 41d0f7a0_ed36_9f0f_d0d6_f403e4f50763 9d025481_71dc_8fbb_c07e_b6e74a08a45a["getHash"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 9d025481_71dc_8fbb_c07e_b6e74a08a45a 1948f092_e5a5_076b_2f59_79ef22dec191["injectQuery"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 1948f092_e5a5_076b_2f59_79ef22dec191 a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> a4adb1a7_cf54_091f_eb63_8217e684a8e1 0850ad90_f980_60a3_ab1f_b17433109b74["prettifyUrl"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 0850ad90_f980_60a3_ab1f_b17433109b74 45981d85_cbdd_e969_8c88_c17072ea0eda["build.ts"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 45981d85_cbdd_e969_8c88_c17072ea0eda 8a1be4dc_fab4_3c44_dfe9_6115f2fdf4e8["BuildEnvironment"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 8a1be4dc_fab4_3c44_dfe9_6115f2fdf4e8 5f248dff_9bc5_81c9_2fb1_99ac1026a9ef["ChunkMetadataMap"] 971bf58d_477c_c4d8_0c3b_735e572044c4 --> 5f248dff_9bc5_81c9_2fb1_99ac1026a9ef style 971bf58d_477c_c4d8_0c3b_735e572044c4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import path from 'node:path'
import MagicString from 'magic-string'
import type { RolldownOutput, RollupError } from 'rolldown'
import colors from 'picocolors'
import { type ImportSpecifier, init, parse } from 'es-module-lexer'
import { viteWebWorkerPostPlugin as nativeWebWorkerPostPlugin } from 'rolldown/experimental'
import type { ResolvedConfig } from '../config'
import { type Plugin, perEnvironmentPlugin } from '../plugin'
import { ENV_ENTRY, ENV_PUBLIC_PATH } from '../constants'
import {
encodeURIPath,
getHash,
injectQuery,
normalizePath,
prettifyUrl,
urlRE,
} from '../utils'
import {
BuildEnvironment,
ChunkMetadataMap,
createToImportMetaURLBasedRelativeRuntime,
injectEnvironmentToHooks,
onRollupLog,
toOutputFilePathInJS,
} from '../build'
import { cleanUrl } from '../../shared/utils'
import type { Logger } from '../logger'
import { fileToUrl, toOutputFilePathInJSForBundledDev } from './asset'
type WorkerBundle = {
entryFilename: string
entryCode: string
entryUrlPlaceholder: string
referencedAssets: Set<string>
watchedFiles: string[]
}
type WorkerBundleAsset = {
fileName: string
/** @deprecated */
originalFileName: string | null
originalFileNames: string[]
source: string | Uint8Array
}
class WorkerOutputCache {
/**
* worker bundle information for each input id
* used to bundle the same worker file only once
*/
private bundles = new Map</* inputId */ string, WorkerBundle>()
/** list of assets emitted for the worker bundles */
private assets = new Map<string, WorkerBundleAsset>()
private fileNameHash = new Map<
/* hash */ string,
/* entryFilename */ string
>()
private invalidatedBundles = new Set</* inputId */ string>()
saveWorkerBundle(
// ... (611 more lines)
Domain
Subdomains
Classes
Dependencies
- BuildEnvironment
- ChunkMetadataMap
- Logger
- ResolvedConfig
- asset.ts
- build.ts
- cleanUrl
- config.ts
- constants.ts
- createToImportMetaURLBasedRelativeRuntime
- encodeURIPath
- es-module-lexer
- experimental
- fileToUrl
- getHash
- injectEnvironmentToHooks
- injectQuery
- logger.ts
- magic-string
- node:path
- normalizePath
- onRollupLog
- perEnvironmentPlugin
- picocolors
- plugin.ts
- prettifyUrl
- rolldown
- toOutputFilePathInJS
- toOutputFilePathInJSForBundledDev
- utils.ts
- utils.ts
Imported By
Source
Frequently Asked Questions
What does worker.ts do?
worker.ts is a source file in the vite codebase, written in typescript. It belongs to the PluginSystem domain, LegacySupport subdomain.
What functions are defined in worker.ts?
worker.ts defines 5 function(s): bundleWorkerEntry, isSameContent, webWorkerPlugin, webWorkerPostPlugin, workerFileToUrl.
What does worker.ts depend on?
worker.ts imports 31 module(s): BuildEnvironment, ChunkMetadataMap, Logger, ResolvedConfig, asset.ts, build.ts, cleanUrl, config.ts, and 23 more.
What files import worker.ts?
worker.ts is imported by 5 file(s): build.ts, dynamicImportVars.ts, importAnalysis.ts, index.ts, workerImportMetaUrl.ts.
Where is worker.ts in the architecture?
worker.ts is located at packages/vite/src/node/plugins/worker.ts (domain: PluginSystem, subdomain: LegacySupport, directory: packages/vite/src/node/plugins).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free