(code, chunk, outputOptions)
| 136 | }, |
| 137 | |
| 138 | renderChunk(code, chunk, outputOptions) { |
| 139 | // when building the worker URLs are replaced with some placeholders |
| 140 | // here we replace those placeholders with the final file names respecting chunks |
| 141 | |
| 142 | let s: MagicString; |
| 143 | const result = () => { |
| 144 | return ( |
| 145 | s && { |
| 146 | code: s.toString(), |
| 147 | map: resolvedConfig.build.sourcemap ? s.generateMap({ hires: 'boundary' }) : null |
| 148 | } |
| 149 | ); |
| 150 | }; |
| 151 | workerAssetUrlRE.lastIndex = 0; |
| 152 | if (workerAssetUrlRE.test(code)) { |
| 153 | const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime( |
| 154 | outputOptions.format, |
| 155 | resolvedConfig.isWorker |
| 156 | ); |
| 157 | |
| 158 | s = new MagicString(code); |
| 159 | workerAssetUrlRE.lastIndex = 0; |
| 160 | |
| 161 | // Replace "VITE_WORKER_ASSET__5aa0ddc0" using relative paths |
| 162 | const workerMap = workerCache.get(resolvedConfig.mainConfig || resolvedConfig)!; |
| 163 | const { fileNameHash } = workerMap; |
| 164 | |
| 165 | let match: RegExpExecArray | null = workerAssetUrlRE.exec(code); |
| 166 | while (match) { |
| 167 | const [full, hash] = match; |
| 168 | const filename = fileNameHash.get(hash)!; |
| 169 | const replacement = toOutputFilePathInJS( |
| 170 | filename, |
| 171 | 'asset', |
| 172 | chunk.fileName, |
| 173 | 'js', |
| 174 | resolvedConfig, |
| 175 | toRelativeRuntime |
| 176 | ); |
| 177 | const replacementString = |
| 178 | typeof replacement === 'string' |
| 179 | ? JSON.stringify(encodeURIPath(replacement)).slice(1, -1) |
| 180 | : `"+${replacement.runtime}+"`; |
| 181 | s.update(match.index, match.index + full.length, replacementString); |
| 182 | match = workerAssetUrlRE.exec(code); |
| 183 | } |
| 184 | } |
| 185 | return result(); |
| 186 | }, |
| 187 | |
| 188 | generateBundle(_, bundle) { |
| 189 | if (isWorker) { |
nothing calls this directly
no test coverage detected