* Emits a deprecation warning for invalid segment in module resolution. * @param {string} target - The target module. * @param {string} request - The requested module. * @param {string} match - The matched module. * @param {string} pjsonUrl - The package.json URL. * @param {boolean} internal -
(target, request, match, pjsonUrl, internal, base, isTarget)
| 96 | * @param {boolean} isTarget - Whether the target is a module. |
| 97 | */ |
| 98 | function emitInvalidSegmentDeprecation(target, request, match, pjsonUrl, internal, base, isTarget) { |
| 99 | if (process.noDeprecation) { |
| 100 | return; |
| 101 | } |
| 102 | const pjsonPath = fileURLToPath(pjsonUrl); |
| 103 | const double = RegExpPrototypeExec(doubleSlashRegEx, isTarget ? target : request) !== null; |
| 104 | process.emitWarning( |
| 105 | `Use of deprecated ${double ? 'double slash' : |
| 106 | 'leading or trailing slash matching'} resolving "${target}" for module ` + |
| 107 | `request "${request}" ${request !== match ? `matched to "${match}" ` : '' |
| 108 | }in the "${internal ? 'imports' : 'exports'}" field module resolution of the package at ${ |
| 109 | pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ''}.`, |
| 110 | 'DeprecationWarning', |
| 111 | 'DEP0166', |
| 112 | ); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Emits a deprecation warning if the given URL is a module and |
no test coverage detected