(source, importer)
| 262 | }, |
| 263 | |
| 264 | async transform(source, importer) { |
| 265 | const environment = this.environment as DevEnvironment |
| 266 | const ssr = environment.config.consumer === 'server' |
| 267 | const moduleGraph = environment.moduleGraph |
| 268 | |
| 269 | if (canSkipImportAnalysis(importer)) { |
| 270 | debug?.(colors.dim(`[skipped] ${prettifyUrl(importer, root)}`)) |
| 271 | return null |
| 272 | } |
| 273 | |
| 274 | const msAtStart = debug ? performance.now() : 0 |
| 275 | await init |
| 276 | let imports!: readonly ImportSpecifier[] |
| 277 | let exports!: readonly ExportSpecifier[] |
| 278 | source = stripBomTag(source) |
| 279 | try { |
| 280 | ;[imports, exports] = parseImports(source) |
| 281 | } catch (_e: unknown) { |
| 282 | const e = _e as EsModuleLexerParseError |
| 283 | const { message, showCodeFrame } = createParseErrorInfo( |
| 284 | importer, |
| 285 | source, |
| 286 | ) |
| 287 | this.error(message, showCodeFrame ? e.idx : undefined) |
| 288 | } |
| 289 | |
| 290 | const depsOptimizer = environment.depsOptimizer |
| 291 | |
| 292 | // since we are already in the transform phase of the importer, it must |
| 293 | // have been loaded so its entry is guaranteed in the module graph. |
| 294 | const importerModule = moduleGraph.getModuleById(importer) |
| 295 | if (!importerModule) { |
| 296 | // This request is no longer valid. It could happen for optimized deps |
| 297 | // requests. A full reload is going to request this id again. |
| 298 | // Throwing an outdated error so we properly finish the request with a |
| 299 | // 504 sent to the browser. |
| 300 | throwOutdatedRequest(importer) |
| 301 | } |
| 302 | |
| 303 | if ( |
| 304 | !imports.length && |
| 305 | !(this as unknown as TransformPluginContext)._addedImports |
| 306 | ) { |
| 307 | const prunedImports = await moduleGraph.updateModuleInfo( |
| 308 | importerModule, |
| 309 | new Set(), |
| 310 | null, |
| 311 | new Set(), |
| 312 | null, |
| 313 | false, |
| 314 | ) |
| 315 | if (prunedImports) { |
| 316 | handlePrunedModules(prunedImports, environment) |
| 317 | } |
| 318 | debug?.( |
| 319 | `${timeFrom(msAtStart)} ${colors.dim( |
| 320 | `[no imports] ${prettifyUrl(importer, root)}`, |
| 321 | )}`, |
nothing calls this directly
no test coverage detected