(from: string, moduleName?: string)
| 946 | // Public entry for `Runtime.unstable_importModule`. Runtime keeps the |
| 947 | // public method as the override seam; this is the body. |
| 948 | async loadAndEvaluate(from: string, moduleName?: string): Promise<unknown> { |
| 949 | invariant( |
| 950 | runtimeSupportsVmModules, |
| 951 | 'You need to run with a version of node that supports ES Modules in the VM API. See https://jestjs.io/docs/ecmascript-modules', |
| 952 | ); |
| 953 | const [specifierPath, query] = (moduleName ?? '').split('?'); |
| 954 | const modulePath = await this.resolution.resolveEsmAsync( |
| 955 | from, |
| 956 | specifierPath, |
| 957 | ); |
| 958 | const module = await this.loadEsmModule(modulePath, query); |
| 959 | return this.linkAndEvaluateModule(module); |
| 960 | } |
| 961 | |
| 962 | private async loadEsmModule( |
| 963 | modulePath: string, |
no test coverage detected