* This method is usually called indirectly as part of the loading processes. * Use directly with caution. * @param {string} specifier The first parameter of an `import()` expression. * @param {string} parentURL Path of the parent importing the module. * @param {Record } im
(specifier, parentURL, importAttributes, phase = kEvaluationPhase, isEntryPoint = false)
| 628 | * @returns {Promise<ModuleExports>} |
| 629 | */ |
| 630 | async import(specifier, parentURL, importAttributes, phase = kEvaluationPhase, isEntryPoint = false) { |
| 631 | return onImport.tracePromise(async () => { |
| 632 | const request = { specifier, phase, attributes: importAttributes, __proto__: null }; |
| 633 | let moduleJob; |
| 634 | try { |
| 635 | moduleJob = await this.getOrCreateModuleJob(parentURL, request); |
| 636 | } catch (e) { |
| 637 | if (e?.code === 'ERR_ASYNC_LOADER_REQUEST_NEVER_SETTLED') { |
| 638 | return new Promise(() => {}); |
| 639 | } |
| 640 | throw e; |
| 641 | } |
| 642 | if (phase === kSourcePhase) { |
| 643 | const module = await moduleJob.modulePromise; |
| 644 | return module.getModuleSourceObject(); |
| 645 | } |
| 646 | const { module } = await moduleJob.run(isEntryPoint); |
| 647 | return module.getNamespace(); |
| 648 | }, { |
| 649 | __proto__: null, |
| 650 | parentURL, |
| 651 | url: specifier, |
| 652 | }); |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * @see {@link AsyncLoaderHooks.register} |
no test coverage detected