diff --git a/src/features/import-maps.js b/src/features/import-maps.js index 3d6a66e2..130ba851 100644 --- a/src/features/import-maps.js +++ b/src/features/import-maps.js @@ -19,6 +19,11 @@ systemJSPrototype.prepareImport = function (doProcessScripts) { } return importMapPromise; }; + +systemJSPrototype.getImportMap = function () { + return JSON.parse(JSON.stringify(importMap)); +}; + if (hasDocument) { processScripts(); window.addEventListener('DOMContentLoaded', processScripts); diff --git a/test/system-core.mjs b/test/system-core.mjs index 4e3d96f4..e6556810 100644 --- a/test/system-core.mjs +++ b/test/system-core.mjs @@ -272,6 +272,17 @@ describe('Core API', function () { assert([...loader.entries()].some(entry => entry[0] === 'http://i' && entry[1].a === 'b')); }) + + it('Supports System.getImportMap', function () { + const importMap = loader.getImportMap(); + + assert( + Object.hasOwn(importMap, 'imports') && + Object.hasOwn(importMap, 'scopes') && + Object.hasOwn(importMap, 'depcache') && + Object.hasOwn(importMap, 'integrity') + ); + }) }); });