MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / bundleWorkerEntry

Function bundleWorkerEntry

packages/vite/src/bridge/worker.ts:89–141  ·  view source on GitHub ↗
(config: ResolvedConfig, id: string)

Source from the content-addressed store, hash-verified

87}
88
89async function bundleWorkerEntry(config: ResolvedConfig, id: string): Promise<BundledWorkerChunk> {
90 const input = cleanUrl(id);
91 const bundleChain = config.bundleChain ?? [];
92 const newBundleChain = [...bundleChain, input];
93 if (bundleChain.includes(input)) {
94 throw new Error(
95 `Circular worker imports detected. Vite does not support it. Import chain: ${newBundleChain.join(' -> ')}`
96 );
97 }
98
99 const { plugins, format } = config.worker;
100 // Vite 8 exposes `rolldownOptions`; Vite 7 only `rollupOptions`.
101 const workerOptionsCarrier = config.worker as { rolldownOptions?: any; rollupOptions?: any };
102 const workerBundlerOptions = workerOptionsCarrier.rolldownOptions ?? workerOptionsCarrier.rollupOptions;
103
104 const workerConfig = await plugins(newBundleChain);
105 const workerEnvironment = new BuildEnvironment('client', workerConfig);
106 await workerEnvironment.init();
107
108 const wrappedPlugins = workerEnvironment.plugins.map(p => injectEnvironmentToHooks(workerEnvironment, p));
109
110 const workerOutputConfig = workerBundlerOptions.output;
111 const outputConfig = workerOutputConfig
112 ? Array.isArray(workerOutputConfig)
113 ? workerOutputConfig[0] || {}
114 : workerOutputConfig
115 : {};
116
117 const generateOptions = {
118 entryFileNames: path.posix.join(config.build.assetsDir, '[name]-[hash].js'),
119 chunkFileNames: path.posix.join(config.build.assetsDir, '[name]-[hash].js'),
120 assetFileNames: path.posix.join(config.build.assetsDir, '[name]-[hash].[ext]'),
121 ...outputConfig,
122 format,
123 sourcemap: config.build.sourcemap
124 };
125
126 let chunk: BundledWorkerChunk;
127 if (detectBundler(config) === BundlerKind.Rolldown) {
128 chunk = await bundleWorkerEntryRolldown(
129 config,
130 input,
131 workerBundlerOptions,
132 wrappedPlugins,
133 generateOptions,
134 workerEnvironment
135 );
136 } else {
137 chunk = await bundleWorkerEntryRollup(config, input, workerBundlerOptions, wrappedPlugins, generateOptions);
138 }
139
140 return emitSourcemapForWorkerEntry(config, chunk);
141}
142
143// Rollup path (Vite 7 and earlier).
144async function bundleWorkerEntryRollup(

Callers 1

workerFileToUrlFunction · 0.85

Calls 11

cleanUrlFunction · 0.90
injectEnvironmentToHooksFunction · 0.90
detectBundlerFunction · 0.90
bundleWorkerEntryRollupFunction · 0.85
includesMethod · 0.80
isArrayMethod · 0.80
joinMethod · 0.45
initMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected