* Similar to resolve, but the results are always synchronously returned. If there are any * asynchronous resolve hooks from module.register(), it will block until the results are returned * from the loader thread for this to be synchronous. * This is here to support `import.meta.res
(parentURL, request, shouldSkipSyncHooks = false)
| 738 | * @returns {ResolveResult} |
| 739 | */ |
| 740 | resolveSync(parentURL, request, shouldSkipSyncHooks = false) { |
| 741 | const specifier = `${request.specifier}`; |
| 742 | const importAttributes = request.attributes ?? kEmptyObject; |
| 743 | // Use an output parameter to track the state and avoid polluting the user-visible resolve results. |
| 744 | const out = { isResolvedByDefaultResolve: false, __proto__: null }; |
| 745 | |
| 746 | let result; |
| 747 | let isResolvedBySyncHooks = false; |
| 748 | if (!shouldSkipSyncHooks && syncResolveHooks.length) { |
| 749 | // Has module.registerHooks() hooks, chain the asynchronous hooks in the default step. |
| 750 | result = resolveWithSyncHooks(specifier, parentURL, importAttributes, this.#defaultConditions, |
| 751 | this.#resolveAndMaybeBlockOnLoaderThread.bind(this, out)); |
| 752 | // If the default step ran, sync hooks did not short-circuit the resolution. |
| 753 | isResolvedBySyncHooks = !out.isResolvedByDefaultResolve; |
| 754 | } else { |
| 755 | const context = { |
| 756 | ...request, |
| 757 | conditions: this.#defaultConditions, |
| 758 | parentURL, |
| 759 | importAttributes, |
| 760 | __proto__: null, |
| 761 | }; |
| 762 | result = this.#resolveAndMaybeBlockOnLoaderThread(out, specifier, context); |
| 763 | } |
| 764 | result.isResolvedBySyncHooks = isResolvedBySyncHooks; |
| 765 | return result; |
| 766 | } |
| 767 | |
| 768 | /** |
| 769 | * Provide source that is understood by one of Node's translators. Handles customization hooks, |
no test coverage detected