* @param {URL['href']} url * @param {LoadContext} [context] * @returns {LoadReturn}
(url, context = kEmptyObject)
| 134 | * @returns {LoadReturn} |
| 135 | */ |
| 136 | function defaultLoadSync(url, context = kEmptyObject) { |
| 137 | let responseURL = url; |
| 138 | const { importAttributes } = context; |
| 139 | let { |
| 140 | format, |
| 141 | source, |
| 142 | } = context; |
| 143 | |
| 144 | const urlInstance = new URL(url); |
| 145 | |
| 146 | throwIfUnsupportedURLScheme(urlInstance, false); |
| 147 | |
| 148 | if (urlInstance.protocol === 'node:') { |
| 149 | source = null; |
| 150 | format ??= 'builtin'; |
| 151 | } else if (format === 'addon') { |
| 152 | // Skip loading addon file content. It must be loaded with dlopen from file system. |
| 153 | source = null; |
| 154 | } else { |
| 155 | if (source == null) { |
| 156 | ({ responseURL, source } = getSourceSync(urlInstance, context)); |
| 157 | context = { __proto__: context, source }; |
| 158 | } |
| 159 | |
| 160 | // Now that we have the source for the module, run `defaultGetFormat` to detect its format. |
| 161 | format ??= defaultGetFormat(urlInstance, context); |
| 162 | } |
| 163 | validateAttributes(url, format, importAttributes); |
| 164 | |
| 165 | return { |
| 166 | __proto__: null, |
| 167 | format, |
| 168 | responseURL, |
| 169 | source, |
| 170 | }; |
| 171 | } |
| 172 | |
| 173 | |
| 174 | /** |
no test coverage detected
searching dependent graphs…