( node: EnvironmentModuleNode, traversedModules: Set<EnvironmentModuleNode>, boundaries: PropagationBoundary[], currentChain: EnvironmentModuleNode[] = [node], )
| 797 | } |
| 798 | |
| 799 | function propagateUpdate( |
| 800 | node: EnvironmentModuleNode, |
| 801 | traversedModules: Set<EnvironmentModuleNode>, |
| 802 | boundaries: PropagationBoundary[], |
| 803 | currentChain: EnvironmentModuleNode[] = [node], |
| 804 | ): HasDeadEnd { |
| 805 | if (traversedModules.has(node)) { |
| 806 | return false |
| 807 | } |
| 808 | traversedModules.add(node) |
| 809 | |
| 810 | // #7561 |
| 811 | // if the imports of `node` have not been analyzed, then `node` has not |
| 812 | // been loaded in the browser and we should stop propagation. |
| 813 | if (node.id && node.isSelfAccepting === undefined) { |
| 814 | debugHmr?.( |
| 815 | `[propagate update] stop propagation because not analyzed: ${colors.dim( |
| 816 | node.id, |
| 817 | )}`, |
| 818 | ) |
| 819 | return false |
| 820 | } |
| 821 | |
| 822 | if (node.isSelfAccepting) { |
| 823 | // isSelfAccepting is only true for js and css |
| 824 | const boundary = node as EnvironmentModuleNode & { type: 'js' | 'css' } |
| 825 | boundaries.push({ |
| 826 | boundary, |
| 827 | acceptedVia: boundary, |
| 828 | isWithinCircularImport: isNodeWithinCircularImports(node, currentChain), |
| 829 | }) |
| 830 | return false |
| 831 | } |
| 832 | |
| 833 | // A partially accepted module with no importers is considered self accepting, |
| 834 | // because the deal is "there are parts of myself I can't self accept if they |
| 835 | // are used outside of me". |
| 836 | // Also, the imported module (this one) must be updated before the importers, |
| 837 | // so that they do get the fresh imported module when/if they are reloaded. |
| 838 | if (node.acceptedHmrExports) { |
| 839 | // acceptedHmrExports is only true for js and css |
| 840 | const boundary = node as EnvironmentModuleNode & { type: 'js' | 'css' } |
| 841 | boundaries.push({ |
| 842 | boundary, |
| 843 | acceptedVia: boundary, |
| 844 | isWithinCircularImport: isNodeWithinCircularImports(node, currentChain), |
| 845 | }) |
| 846 | } else { |
| 847 | if (!node.importers.size) { |
| 848 | return true |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | for (const importer of node.importers) { |
| 853 | const subChain = currentChain.concat(importer) |
| 854 | |
| 855 | if (importer.acceptedHmrDeps.has(node)) { |
| 856 | // acceptedHmrDeps has value only for js and css |
no test coverage detected