(
config: ResolvedConfig,
input: string,
bundlerOptions: any,
plugins: any,
generateOptions: any,
workerEnvironment: BuildEnvironment
)
| 173 | |
| 174 | // Rolldown path (Vite 8+). |
| 175 | async function bundleWorkerEntryRolldown( |
| 176 | config: ResolvedConfig, |
| 177 | input: string, |
| 178 | bundlerOptions: any, |
| 179 | plugins: any, |
| 180 | generateOptions: any, |
| 181 | workerEnvironment: BuildEnvironment |
| 182 | ): Promise<BundledWorkerChunk> { |
| 183 | const { rolldown } = await import('rolldown'); |
| 184 | const workerBuildTarget = workerEnvironment.config.build.target; |
| 185 | const bundle = await rolldown({ |
| 186 | ...bundlerOptions, |
| 187 | input, |
| 188 | plugins, |
| 189 | transform: { |
| 190 | target: workerBuildTarget === false ? undefined : workerBuildTarget, |
| 191 | ...bundlerOptions.transform, |
| 192 | define: { |
| 193 | ...bundlerOptions.transform?.define, |
| 194 | 'process.env.NODE_ENV': 'process.env.NODE_ENV' |
| 195 | } |
| 196 | }, |
| 197 | moduleTypes: { |
| 198 | '.css': 'js', |
| 199 | ...bundlerOptions.moduleTypes |
| 200 | }, |
| 201 | preserveEntrySignatures: false, |
| 202 | experimental: { |
| 203 | ...bundlerOptions.experimental, |
| 204 | viteMode: true |
| 205 | } |
| 206 | }); |
| 207 | try { |
| 208 | const { output } = await bundle.generate(generateOptions); |
| 209 | const [outputChunk, ...rest] = output; |
| 210 | for (const o of rest) { |
| 211 | if (o.type === 'asset') { |
| 212 | saveEmitWorkerAsset(config, o); |
| 213 | } else { |
| 214 | saveEmitWorkerAsset(config, { fileName: o.fileName, source: o.code }); |
| 215 | } |
| 216 | } |
| 217 | return outputChunk; |
| 218 | } finally { |
| 219 | await bundle.close(); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L124 |
| 224 | function emitSourcemapForWorkerEntry(config: ResolvedConfig, chunk: BundledWorkerChunk): BundledWorkerChunk { |
no test coverage detected