* Get the singleton package map, initializing on first call. * @returns {PackageMap|null}
()
| 258 | * @returns {PackageMap|null} |
| 259 | */ |
| 260 | function getPackageMap() { |
| 261 | if (packageMap !== undefined) { return packageMap; } |
| 262 | |
| 263 | packageMapPath = getPackageMapPath(); |
| 264 | if (!packageMapPath) { |
| 265 | packageMap = null; |
| 266 | return null; |
| 267 | } |
| 268 | |
| 269 | emitExperimentalWarning('Package maps'); |
| 270 | |
| 271 | try { |
| 272 | packageMap = loadPackageMap(pathResolve(packageMapPath)); |
| 273 | } catch (err) { |
| 274 | // Fallback to an empty package map to avoid repeatedly trying |
| 275 | // to load the broken package map file. Subsequent resolutions |
| 276 | // will still fail to resolve due to the package map being empty. |
| 277 | packageMap = new PackageMap(packageMapPath, { packages: {} }); |
| 278 | throw err; |
| 279 | } |
| 280 | |
| 281 | return packageMap; |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * Check if the package map is enabled. |
no test coverage detected
searching dependent graphs…