* Get the absolute path to the main entry point. * @param {string} main - Entry point path * @returns {string|undefined}
(main)
| 27 | * @returns {string|undefined} |
| 28 | */ |
| 29 | function resolveMainPath(main) { |
| 30 | /** @type {string} */ |
| 31 | let mainPath; |
| 32 | // Extension searching for the main entry point is supported for backward compatibility. |
| 33 | // Module._findPath is monkey-patchable here. |
| 34 | const { Module } = require('internal/modules/cjs/loader'); |
| 35 | mainPath = Module._findPath(path.resolve(main), null, true); |
| 36 | if (!mainPath) { return; } |
| 37 | |
| 38 | const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main'); |
| 39 | if (!preserveSymlinksMain) { |
| 40 | const { toRealPath } = require('internal/modules/helpers'); |
| 41 | mainPath = toRealPath(mainPath); |
| 42 | } |
| 43 | |
| 44 | return mainPath; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Determine whether the main entry point should be loaded through the ESM Loader. |
no test coverage detected
searching dependent graphs…