(nodeModuleName: string, pathInsideNodeModule: string, isBuilt?: boolean)
| 203 | * e.g. pass in `vscode-textmate/release/main.js` |
| 204 | */ |
| 205 | export async function importAMDNodeModule<T>(nodeModuleName: string, pathInsideNodeModule: string, isBuilt?: boolean): Promise<T> { |
| 206 | if (isBuilt === undefined) { |
| 207 | const product = globalThis._VSCODE_PRODUCT_JSON as unknown as IProductConfiguration; |
| 208 | isBuilt = Boolean((product ?? globalThis.vscode?.context?.configuration()?.product)?.commit); |
| 209 | } |
| 210 | |
| 211 | const nodeModulePath = pathInsideNodeModule ? `${nodeModuleName}/${pathInsideNodeModule}` : nodeModuleName; |
| 212 | if (cache.has(nodeModulePath)) { |
| 213 | return cache.get(nodeModulePath)!; |
| 214 | } |
| 215 | let scriptSrc: string; |
| 216 | if (/^\w[\w\d+.-]*:\/\//.test(nodeModulePath)) { |
| 217 | // looks like a URL |
| 218 | // bit of a special case for: src/vs/workbench/services/languageDetection/browser/languageDetectionWebWorker.ts |
| 219 | scriptSrc = nodeModulePath; |
| 220 | } else { |
| 221 | const useASAR = (canASAR && isBuilt && !platform.isWeb); |
| 222 | const actualNodeModulesPath = (useASAR ? nodeModulesAsarPath : nodeModulesPath); |
| 223 | const resourcePath: AppResourcePath = `${actualNodeModulesPath}/${nodeModulePath}`; |
| 224 | scriptSrc = FileAccess.asBrowserUri(resourcePath).toString(true); |
| 225 | } |
| 226 | const result = AMDModuleImporter.INSTANCE.load<T>(scriptSrc); |
| 227 | cache.set(nodeModulePath, result); |
| 228 | return result; |
| 229 | } |
| 230 | |
| 231 | export function resolveAmdNodeModulePath(nodeModuleName: string, pathInsideNodeModule: string): string { |
| 232 | const product = globalThis._VSCODE_PRODUCT_JSON as unknown as IProductConfiguration; |
no test coverage detected
searching dependent graphs…