()
| 90 | * @returns {string} current script source |
| 91 | */ |
| 92 | const getCurrentScriptSource = () => { |
| 93 | // `document.currentScript` is the most accurate way to find the current script, |
| 94 | // but is not supported in all browsers. |
| 95 | if (document.currentScript) { |
| 96 | return /** @type {string} */ (document.currentScript.getAttribute("src")); |
| 97 | } |
| 98 | |
| 99 | // Fallback to getting all scripts running in the document. |
| 100 | const scriptElements = document.scripts || []; |
| 101 | const scriptElementsWithSrc = Array.prototype.filter.call( |
| 102 | scriptElements, |
| 103 | (element) => element.getAttribute("src"), |
| 104 | ); |
| 105 | |
| 106 | if (scriptElementsWithSrc.length > 0) { |
| 107 | const currentScript = |
| 108 | scriptElementsWithSrc[scriptElementsWithSrc.length - 1]; |
| 109 | |
| 110 | return currentScript.getAttribute("src"); |
| 111 | } |
| 112 | |
| 113 | // Fail as there was no script to use. |
| 114 | throw new Error("[webpack-dev-server] Failed to get current script source."); |
| 115 | }; |
| 116 | |
| 117 | /** @typedef {{ hot?: string, ["live-reload"]?: string, progress?: string, reconnect?: string, logging?: LogLevel, overlay?: string, fromCurrentScript?: boolean }} AdditionalParsedURL */ |
| 118 | /** @typedef {Partial<URL> & AdditionalParsedURL} ParsedURL */ |
no outgoing calls
no test coverage detected
searching dependent graphs…