* Adds a new source to the collection.
(
url: string,
contentGetter: ContentGetter,
sourceMapUrl?: string,
inlineSourceRange?: InlineScriptOffset,
contentHash?: string,
)
| 690 | * Adds a new source to the collection. |
| 691 | */ |
| 692 | public async addSource( |
| 693 | url: string, |
| 694 | contentGetter: ContentGetter, |
| 695 | sourceMapUrl?: string, |
| 696 | inlineSourceRange?: InlineScriptOffset, |
| 697 | contentHash?: string, |
| 698 | ): Promise<Source> { |
| 699 | const absolutePath = await this.sourcePathResolver.urlToAbsolutePath({ url }); |
| 700 | this.logger.verbose(LogTag.RuntimeSourceCreate, 'Creating source from url', { |
| 701 | inputUrl: url, |
| 702 | absolutePath, |
| 703 | }); |
| 704 | |
| 705 | const source = new Source( |
| 706 | this, |
| 707 | url, |
| 708 | absolutePath, |
| 709 | contentGetter, |
| 710 | sourceMapUrl && |
| 711 | this.sourcePathResolver.shouldResolveSourceMap({ |
| 712 | sourceMapUrl, |
| 713 | compiledPath: absolutePath || url, |
| 714 | }) |
| 715 | ? sourceMapUrl |
| 716 | : undefined, |
| 717 | inlineSourceRange, |
| 718 | contentHash, |
| 719 | ); |
| 720 | this._addSource(source); |
| 721 | return source; |
| 722 | } |
| 723 | |
| 724 | private async _addSource(source: Source) { |
| 725 | this._sourceByReference.set(source.sourceReference(), source); |
no test coverage detected