(source: Source)
| 722 | } |
| 723 | |
| 724 | private async _addSource(source: Source) { |
| 725 | this._sourceByReference.set(source.sourceReference(), source); |
| 726 | if (source instanceof SourceFromMap) { |
| 727 | this._sourceMapSourcesByUrl.set(source.url, source); |
| 728 | } |
| 729 | |
| 730 | // Some builds, like the Vue starter, generate 'metadata' files for compiled |
| 731 | // files with query strings appended to deduplicate them, or nested inside |
| 732 | // of internal prefixes. If we see a duplicate entries for an absolute path, |
| 733 | // take the shorter of them. |
| 734 | const existingByPath = this._sourceByAbsolutePath.get(source.absolutePath()); |
| 735 | if ( |
| 736 | existingByPath === undefined || |
| 737 | existingByPath.url.length >= source.url.length || |
| 738 | (source instanceof SourceFromMap && |
| 739 | source.compiledToSourceUrl.has(existingByPath as ISourceWithMap)) |
| 740 | ) { |
| 741 | this._sourceByAbsolutePath.set(source.absolutePath(), source); |
| 742 | } |
| 743 | |
| 744 | source.toDap().then(dap => this._dap.loadedSource({ reason: 'new', source: dap })); |
| 745 | |
| 746 | if (!isSourceWithMap(source)) { |
| 747 | return; |
| 748 | } |
| 749 | |
| 750 | const existingSourceMap = this._sourceMaps.get(source.sourceMap.url); |
| 751 | if (existingSourceMap) { |
| 752 | existingSourceMap.compiled.add(source); |
| 753 | if (existingSourceMap.map) { |
| 754 | // If source map has been already loaded, we add sources here. |
| 755 | // Otheriwse, we'll add sources for all compiled after loading the map. |
| 756 | await this._addSourceMapSources(source, existingSourceMap.map); |
| 757 | } |
| 758 | return; |
| 759 | } |
| 760 | |
| 761 | const deferred = getDeferred<void>(); |
| 762 | const sourceMap: SourceMapData = { compiled: new Set([source]), loaded: deferred.promise }; |
| 763 | this._sourceMaps.set(source.sourceMap.url, sourceMap); |
| 764 | |
| 765 | try { |
| 766 | sourceMap.map = await this.sourceMapFactory.load(source.sourceMap.metadata); |
| 767 | } catch (e) { |
| 768 | this._dap.output({ |
| 769 | output: sourceMapParseFailed(source.url, e.message).error.format, |
| 770 | category: 'stderr', |
| 771 | }); |
| 772 | |
| 773 | return deferred.resolve(); |
| 774 | } |
| 775 | |
| 776 | // Source map could have been detached while loading. |
| 777 | if (this._sourceMaps.get(source.sourceMap.url) !== sourceMap) { |
| 778 | return deferred.resolve(); |
| 779 | } |
| 780 | |
| 781 | this.logger.verbose(LogTag.SourceMapParsing, 'Creating sources from source map', { |
no test coverage detected