(config: ResolvedConfig, id: string)
| 62 | * @internal |
| 63 | */ |
| 64 | export async function workerFileToUrl(config: ResolvedConfig, id: string): Promise<string> { |
| 65 | const workerMap = workerCache.get(config.mainConfig || config)!; |
| 66 | let fileName = workerMap.bundle.get(id); |
| 67 | if (!fileName) { |
| 68 | const outputChunk = await bundleWorkerEntry(config, id); |
| 69 | fileName = outputChunk.fileName; |
| 70 | saveEmitWorkerAsset(config, { |
| 71 | fileName, |
| 72 | source: outputChunk.code |
| 73 | }); |
| 74 | workerMap.bundle.set(id, fileName); |
| 75 | } |
| 76 | return encodeWorkerAssetFileName(fileName, workerMap); |
| 77 | } |
| 78 | |
| 79 | // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L149 |
| 80 | function encodeWorkerAssetFileName(fileName: string, workerCache: WorkerCache): string { |
no test coverage detected