(environment: DevEnvironment)
| 615 | } |
| 616 | |
| 617 | async function hmr(environment: DevEnvironment) { |
| 618 | try { |
| 619 | const { options, error } = hotMap.get(environment)! |
| 620 | if (error) { |
| 621 | throw error |
| 622 | } |
| 623 | if (!options.modules.length) { |
| 624 | // html file cannot be hot updated |
| 625 | if (file.endsWith('.html') && environment.name === 'client') { |
| 626 | environment.logger.info( |
| 627 | colors.green(`page reload `) + colors.dim(shortFile), |
| 628 | { |
| 629 | clear: true, |
| 630 | timestamp: true, |
| 631 | }, |
| 632 | ) |
| 633 | environment.hot.send({ |
| 634 | type: 'full-reload', |
| 635 | path: config.server.middlewareMode |
| 636 | ? '*' |
| 637 | : '/' + normalizePath(path.relative(config.root, file)), |
| 638 | }) |
| 639 | } else { |
| 640 | // loaded but not in the module graph, probably not js |
| 641 | debugHmr?.( |
| 642 | `(${environment.name}) [no modules matched] ${colors.dim(shortFile)}`, |
| 643 | ) |
| 644 | } |
| 645 | return |
| 646 | } |
| 647 | |
| 648 | updateModules(environment, shortFile, options.modules, timestamp) |
| 649 | } catch (err) { |
| 650 | environment.hot.send({ |
| 651 | type: 'error', |
| 652 | err: prepareError(err), |
| 653 | }) |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | const hotUpdateEnvironments = |
| 658 | server.config.server.hotUpdateEnvironments ?? |
no test coverage detected