( module: Module, specifier: string | AstNode, importer: string, attributes: Record<string, string> )
| 744 | } |
| 745 | |
| 746 | private async resolveDynamicImport( |
| 747 | module: Module, |
| 748 | specifier: string | AstNode, |
| 749 | importer: string, |
| 750 | attributes: Record<string, string> |
| 751 | ): Promise<ResolvedId | string | null> { |
| 752 | const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [ |
| 753 | specifier, |
| 754 | importer, |
| 755 | { attributes, importerAttributes: module.info.attributes } |
| 756 | ]); |
| 757 | if (typeof specifier !== 'string') { |
| 758 | if (typeof resolution === 'string') { |
| 759 | return resolution; |
| 760 | } |
| 761 | if (!resolution) { |
| 762 | return null; |
| 763 | } |
| 764 | return this.getResolvedIdWithDefaults( |
| 765 | resolution as NormalizedResolveIdWithoutDefaults, |
| 766 | attributes |
| 767 | ); |
| 768 | } |
| 769 | if (resolution == null) { |
| 770 | const existingResolution = module.resolvedIds[specifier]; |
| 771 | if (existingResolution) { |
| 772 | if (doAttributesDiffer(existingResolution.attributes, attributes)) { |
| 773 | this.options.onLog( |
| 774 | LOGLEVEL_WARN, |
| 775 | logInconsistentImportAttributes( |
| 776 | existingResolution.attributes, |
| 777 | attributes, |
| 778 | specifier, |
| 779 | importer |
| 780 | ) |
| 781 | ); |
| 782 | } |
| 783 | return existingResolution; |
| 784 | } |
| 785 | return (module.resolvedIds[specifier] = this.handleInvalidResolvedId( |
| 786 | await this.resolveId( |
| 787 | specifier, |
| 788 | module.id, |
| 789 | EMPTY_OBJECT, |
| 790 | false, |
| 791 | attributes, |
| 792 | module.info.attributes |
| 793 | ), |
| 794 | specifier, |
| 795 | module.id, |
| 796 | attributes |
| 797 | )); |
| 798 | } |
| 799 | return this.handleInvalidResolvedId( |
| 800 | this.getResolvedIdWithDefaults( |
| 801 | this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), |
| 802 | attributes |
| 803 | ), |
no test coverage detected