( environment: DevEnvironment, url: string, options: TransformOptionsInternal, timestamp: number, )
| 148 | } |
| 149 | |
| 150 | async function doTransform( |
| 151 | environment: DevEnvironment, |
| 152 | url: string, |
| 153 | options: TransformOptionsInternal, |
| 154 | timestamp: number, |
| 155 | ) { |
| 156 | const { pluginContainer } = environment |
| 157 | |
| 158 | let module = await environment.moduleGraph.getModuleByUrl(url) |
| 159 | if (module) { |
| 160 | // try use cache from url |
| 161 | const cached = await getCachedTransformResult( |
| 162 | environment, |
| 163 | url, |
| 164 | module, |
| 165 | timestamp, |
| 166 | ) |
| 167 | if (cached) return cached |
| 168 | } |
| 169 | |
| 170 | const resolved = module |
| 171 | ? undefined |
| 172 | : ((await pluginContainer.resolveId(url, undefined)) ?? undefined) |
| 173 | |
| 174 | // resolve |
| 175 | const id = module?.id ?? resolved?.id ?? url |
| 176 | |
| 177 | module ??= environment.moduleGraph.getModuleById(id) |
| 178 | if (module) { |
| 179 | // if a different url maps to an existing loaded id, make sure we relate this url to the id |
| 180 | await environment.moduleGraph._ensureEntryFromUrl(url, undefined, resolved) |
| 181 | // try use cache from id |
| 182 | const cached = await getCachedTransformResult( |
| 183 | environment, |
| 184 | url, |
| 185 | module, |
| 186 | timestamp, |
| 187 | ) |
| 188 | if (cached) return cached |
| 189 | } |
| 190 | |
| 191 | const result = loadAndTransform( |
| 192 | environment, |
| 193 | id, |
| 194 | url, |
| 195 | options, |
| 196 | timestamp, |
| 197 | module, |
| 198 | resolved, |
| 199 | ) |
| 200 | |
| 201 | const { depsOptimizer } = environment |
| 202 | if (!depsOptimizer?.isOptimizedDepFile(id)) { |
| 203 | environment._registerRequestProcessing(id, () => result) |
| 204 | } |
| 205 | |
| 206 | return result |
| 207 | } |
no test coverage detected