* Returns the source types available for this module. * @param {NormalModule} module fresh module * @returns {SourceTypes} available types (do not mutate)
(module)
| 703 | * @returns {SourceTypes} available types (do not mutate) |
| 704 | */ |
| 705 | getTypes(module) { |
| 706 | /** @type {Set<string>} */ |
| 707 | const sourceTypes = new Set(); |
| 708 | const connections = this._moduleGraph.getIncomingConnections(module); |
| 709 | |
| 710 | for (const connection of connections) { |
| 711 | if (!connection.originModule) { |
| 712 | continue; |
| 713 | } |
| 714 | |
| 715 | sourceTypes.add(connection.originModule.type.split("/")[0]); |
| 716 | } |
| 717 | |
| 718 | if ( |
| 719 | (module.buildInfo && |
| 720 | /** @type {AssetModuleBuildInfo} */ (module.buildInfo).dataUrl) || |
| 721 | this.emit === false |
| 722 | ) { |
| 723 | if (sourceTypes.size > 0) { |
| 724 | if ( |
| 725 | sourceTypes.has(JAVASCRIPT_TYPE) && |
| 726 | (sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE)) |
| 727 | ) { |
| 728 | return JAVASCRIPT_AND_ASSET_URL_TYPES; |
| 729 | } else if (sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE)) { |
| 730 | return ASSET_URL_TYPES; |
| 731 | } |
| 732 | return JAVASCRIPT_TYPES; |
| 733 | } |
| 734 | |
| 735 | return NO_TYPES; |
| 736 | } |
| 737 | |
| 738 | if (sourceTypes.size > 0) { |
| 739 | if ( |
| 740 | sourceTypes.has(JAVASCRIPT_TYPE) && |
| 741 | (sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE)) |
| 742 | ) { |
| 743 | return ASSET_AND_JAVASCRIPT_AND_ASSET_URL_TYPES; |
| 744 | } else if (sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE)) { |
| 745 | return ASSET_AND_ASSET_URL_TYPES; |
| 746 | } |
| 747 | return ASSET_AND_JAVASCRIPT_TYPES; |
| 748 | } |
| 749 | |
| 750 | return ASSET_TYPES; |
| 751 | } |
| 752 | |
| 753 | /** |
| 754 | * @returns {boolean} whether getTypes() depends on the module's incoming connections |
nothing calls this directly
no test coverage detected