| 814 | } |
| 815 | |
| 816 | async load( |
| 817 | options: { |
| 818 | id: string |
| 819 | resolveDependencies?: boolean |
| 820 | } & Partial<PartialNull<ModuleOptions>>, |
| 821 | ): Promise<ModuleInfo> { |
| 822 | // We may not have added this to our module graph yet, so ensure it exists |
| 823 | await this._container.moduleGraph?.ensureEntryFromUrl(unwrapId(options.id)) |
| 824 | // Not all options passed to this function make sense in the context of loading individual files, |
| 825 | // but we can at least update the module info properties we support |
| 826 | this._updateModuleInfo(options.id, options) |
| 827 | |
| 828 | const loadResult = await this._container.load(options.id) |
| 829 | const code = typeof loadResult === 'object' ? loadResult?.code : loadResult |
| 830 | if (code != null) { |
| 831 | await this._container.transform(code, options.id) |
| 832 | } |
| 833 | |
| 834 | const moduleInfo = this.getModuleInfo(options.id) |
| 835 | // This shouldn't happen due to calling ensureEntryFromUrl, but 1) our types can't ensure that |
| 836 | // and 2) moduleGraph may not have been provided (though in the situations where that happens, |
| 837 | // we should never have plugins calling this.load) |
| 838 | if (!moduleInfo) throw Error(`Failed to load module with id ${options.id}`) |
| 839 | return moduleInfo |
| 840 | } |
| 841 | |
| 842 | getModuleInfo(id: string): ModuleInfo | null { |
| 843 | return this._container.getModuleInfo(id) |