( resolved: string, id: string, options: InternalResolveOptions, depsOptimizer?: DepsOptimizer, )
| 523 | } |
| 524 | |
| 525 | function ensureVersionQuery( |
| 526 | resolved: string, |
| 527 | id: string, |
| 528 | options: InternalResolveOptions, |
| 529 | depsOptimizer?: DepsOptimizer, |
| 530 | ): string { |
| 531 | if ( |
| 532 | !options.isBuild && |
| 533 | !options.scan && |
| 534 | depsOptimizer && |
| 535 | !(resolved === normalizedClientEntry || resolved === normalizedEnvEntry) |
| 536 | ) { |
| 537 | // Ensure that direct imports of node_modules have the same version query |
| 538 | // as if they would have been imported through a bare import |
| 539 | // Use the original id to do the check as the resolved id may be the real |
| 540 | // file path after symlinks resolution |
| 541 | const isNodeModule = isInNodeModules(id) || isInNodeModules(resolved) |
| 542 | |
| 543 | if (isNodeModule && !DEP_VERSION_RE.test(resolved)) { |
| 544 | const versionHash = depsOptimizer.metadata.browserHash |
| 545 | if (versionHash && isOptimizable(resolved, depsOptimizer.options)) { |
| 546 | resolved = injectQuery(resolved, `v=${versionHash}`) |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | return resolved |
| 551 | } |
| 552 | |
| 553 | export function tryFsResolve( |
| 554 | fsPath: string, |
no test coverage detected