MCPcopy Index your code
hub / github.com/nodejs/node / getPackageMap

Function getPackageMap

lib/internal/modules/package_map.js:260–282  ·  view source on GitHub ↗

* Get the singleton package map, initializing on first call. * @returns {PackageMap|null}

()

Source from the content-addressed store, hash-verified

258 * @returns {PackageMap|null}
259 */
260function 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.

Callers 1

packageMapResolveFunction · 0.85

Calls 2

emitExperimentalWarningFunction · 0.85
loadPackageMapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…