Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsenv/import-map

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/import-map - npm Package Compare versions

Comparing version 6.11.0 to 6.11.1

178

dist/esmodule/main.js

@@ -263,12 +263,12 @@ var createDetailedMessage = function createDetailedMessage(message) {

if (scopes && importer) {
var scopeKeyMatching = Object.keys(scopes).find(function (scopeKey) {
return scopeKey === importer || specifierIsPrefixOf(scopeKey, importer);
var scopeSpecifierMatching = Object.keys(scopes).find(function (scopeSpecifier) {
return scopeSpecifier === importer || specifierIsPrefixOf(scopeSpecifier, importer);
});
if (scopeKeyMatching) {
var scopeValue = scopes[scopeKeyMatching];
var remappingFromScopeImports = applyImports(specifierNormalized, scopeValue);
if (scopeSpecifierMatching) {
var scopeMappings = scopes[scopeSpecifierMatching];
var mappingFromScopes = applyMappings(scopeMappings, specifierNormalized);
if (remappingFromScopeImports !== null) {
return remappingFromScopeImports;
if (mappingFromScopes !== null) {
return mappingFromScopes;
}

@@ -281,6 +281,6 @@ }

if (imports) {
var remappingFromImports = applyImports(specifierNormalized, imports);
var mappingFromImports = applyMappings(imports, specifierNormalized);
if (remappingFromImports !== null) {
return remappingFromImports;
if (mappingFromImports !== null) {
return mappingFromImports;
}

@@ -293,25 +293,25 @@ }

throw new Error(createBareSpecifierError({
throw createBareSpecifierError({
specifier: specifier,
importer: importer
}));
});
};
var applyImports = function applyImports(specifier, imports) {
var importKeyArray = Object.keys(imports);
var applyMappings = function applyMappings(mappings, specifier) {
var specifierCandidates = Object.keys(mappings);
var i = 0;
while (i < importKeyArray.length) {
var importKey = importKeyArray[i];
while (i < specifierCandidates.length) {
var specifierCandidate = specifierCandidates[i];
i++;
if (importKey === specifier) {
var importValue = imports[importKey];
return importValue;
if (specifierCandidate === specifier) {
var address = mappings[specifierCandidate];
return address;
}
if (specifierIsPrefixOf(importKey, specifier)) {
var _importValue = imports[importKey];
var afterImportKey = specifier.slice(importKey.length);
return tryUrlResolution(afterImportKey, _importValue);
if (specifierIsPrefixOf(specifierCandidate, specifier)) {
var _address = mappings[specifierCandidate];
var afterSpecifier = specifier.slice(specifierCandidate.length);
return tryUrlResolution(afterSpecifier, _address);
}

@@ -397,3 +397,3 @@ }

if (leftHasImports && rightHasImports) {
importMap.imports = composeTwoImports(leftImports, rightImports);
importMap.imports = composeTwoMappings(leftImports, rightImports);
} else if (leftHasImports) {

@@ -421,6 +421,6 @@ importMap.imports = _objectSpread({}, leftImports);

var composeTwoImports = function composeTwoImports(leftImports, rightImports) {
var topLevelMappings = {};
Object.keys(leftImports).forEach(function (leftSpecifier) {
if (objectHasKey(rightImports, leftSpecifier)) {
var composeTwoMappings = function composeTwoMappings(leftMappings, rightMappings) {
var mappings = {};
Object.keys(leftMappings).forEach(function (leftSpecifier) {
if (objectHasKey(rightMappings, leftSpecifier)) {
// will be overidden

@@ -430,12 +430,12 @@ return;

var leftAddress = leftImports[leftSpecifier];
var rightSpecifier = Object.keys(rightImports).find(function (rightSpecifier) {
var leftAddress = leftMappings[leftSpecifier];
var rightSpecifier = Object.keys(rightMappings).find(function (rightSpecifier) {
return compareAddressAndSpecifier(leftAddress, rightSpecifier);
});
topLevelMappings[leftSpecifier] = rightSpecifier ? rightImports[rightSpecifier] : leftAddress;
mappings[leftSpecifier] = rightSpecifier ? rightMappings[rightSpecifier] : leftAddress;
});
Object.keys(rightImports).forEach(function (rightSpecifier) {
topLevelMappings[rightSpecifier] = rightImports[rightSpecifier];
Object.keys(rightMappings).forEach(function (rightSpecifier) {
mappings[rightSpecifier] = rightMappings[rightSpecifier];
});
return topLevelMappings;
return mappings;
};

@@ -453,12 +453,12 @@

var composeTwoScopes = function composeTwoScopes(leftScopes, rightScopes, topLevelRemappings) {
var scopedRemappings = {};
var composeTwoScopes = function composeTwoScopes(leftScopes, rightScopes, imports) {
var scopes = {};
Object.keys(leftScopes).forEach(function (leftScopeKey) {
if (objectHasKey(rightScopes, leftScopeKey)) {
// will be merged
scopedRemappings[leftScopeKey] = leftScopes[leftScopeKey];
scopes[leftScopeKey] = leftScopes[leftScopeKey];
return;
}
var topLevelSpecifier = Object.keys(topLevelRemappings).find(function (topLevelSpecifierCandidate) {
var topLevelSpecifier = Object.keys(imports).find(function (topLevelSpecifierCandidate) {
return compareAddressAndSpecifier(leftScopeKey, topLevelSpecifierCandidate);

@@ -468,15 +468,15 @@ });

if (topLevelSpecifier) {
scopedRemappings[topLevelRemappings[topLevelSpecifier]] = leftScopes[leftScopeKey];
scopes[imports[topLevelSpecifier]] = leftScopes[leftScopeKey];
} else {
scopedRemappings[leftScopeKey] = leftScopes[leftScopeKey];
scopes[leftScopeKey] = leftScopes[leftScopeKey];
}
});
Object.keys(rightScopes).forEach(function (rightScopeKey) {
if (objectHasKey(scopedRemappings, rightScopeKey)) {
scopedRemappings[rightScopeKey] = composeTwoImports(scopedRemappings[rightScopeKey], rightScopes[rightScopeKey]);
if (objectHasKey(scopes, rightScopeKey)) {
scopes[rightScopeKey] = composeTwoMappings(scopes[rightScopeKey], rightScopes[rightScopeKey]);
} else {
scopedRemappings[rightScopeKey] = _objectSpread({}, rightScopes[rightScopeKey]);
scopes[rightScopeKey] = _objectSpread({}, rightScopes[rightScopeKey]);
}
});
return scopedRemappings;
return scopes;
};

@@ -609,3 +609,3 @@

if (imports) {
importMapRelative.imports = makeImportsRelativeTo(imports, makeRelativeTo) || imports;
importMapRelative.imports = makeMappingsRelativeTo(imports, makeRelativeTo) || imports;
}

@@ -616,3 +616,3 @@

if (scopes) {
importMapRelative.scopes = makeScopedRemappingRelativeTo(scopes, makeRelativeTo) || scopes;
importMapRelative.scopes = makeScopesRelativeTo(scopes, makeRelativeTo) || scopes;
} // nothing changed

@@ -628,44 +628,44 @@

var makeScopedRemappingRelativeTo = function makeScopedRemappingRelativeTo(scopes, makeRelativeTo) {
var scopesTransformed = {};
var scopesRemaining = {};
var makeMappingsRelativeTo = function makeMappingsRelativeTo(mappings, makeRelativeTo) {
var mappingsTransformed = {};
var mappingsRemaining = {};
var transformed = false;
Object.keys(scopes).forEach(function (scopeKey) {
var scopeValue = scopes[scopeKey];
var scopeKeyRelative = makeRelativeTo(scopeKey, "address");
var scopeValueRelative = makeImportsRelativeTo(scopeValue, makeRelativeTo);
Object.keys(mappings).forEach(function (specifier) {
var address = mappings[specifier];
var specifierRelative = makeRelativeTo(specifier, "specifier");
var addressRelative = makeRelativeTo(address, "address");
if (scopeKeyRelative) {
if (specifierRelative) {
transformed = true;
scopesTransformed[scopeKeyRelative] = scopeValueRelative || scopeValue;
} else if (scopeValueRelative) {
mappingsTransformed[specifierRelative] = addressRelative || address;
} else if (addressRelative) {
transformed = true;
scopesTransformed[scopeKey] = scopeValueRelative;
mappingsTransformed[specifier] = addressRelative;
} else {
scopesRemaining[scopeKey] = scopeValueRelative;
mappingsRemaining[specifier] = address;
}
});
return transformed ? _objectSpread(_objectSpread({}, scopesTransformed), scopesRemaining) : null;
return transformed ? _objectSpread(_objectSpread({}, mappingsTransformed), mappingsRemaining) : null;
};
var makeImportsRelativeTo = function makeImportsRelativeTo(imports, makeRelativeTo) {
var importsTransformed = {};
var importsRemaining = {};
var makeScopesRelativeTo = function makeScopesRelativeTo(scopes, makeRelativeTo) {
var scopesTransformed = {};
var scopesRemaining = {};
var transformed = false;
Object.keys(imports).forEach(function (importKey) {
var importValue = imports[importKey];
var importKeyRelative = makeRelativeTo(importKey, "specifier");
var importValueRelative = makeRelativeTo(importValue, "address");
Object.keys(scopes).forEach(function (scopeSpecifier) {
var scopeMappings = scopes[scopeSpecifier];
var scopeSpecifierRelative = makeRelativeTo(scopeSpecifier, "address");
var scopeMappingsRelative = makeMappingsRelativeTo(scopeMappings, makeRelativeTo);
if (importKeyRelative) {
if (scopeSpecifierRelative) {
transformed = true;
importsTransformed[importKeyRelative] = importValueRelative || importValue;
} else if (importValueRelative) {
scopesTransformed[scopeSpecifierRelative] = scopeMappingsRelative || scopeMappings;
} else if (scopeMappingsRelative) {
transformed = true;
importsTransformed[importKey] = importValueRelative;
scopesTransformed[scopeSpecifier] = scopeMappingsRelative;
} else {
importsRemaining[importKey] = importValue;
scopesRemaining[scopeSpecifier] = scopeMappingsRelative;
}
});
return transformed ? _objectSpread(_objectSpread({}, importsTransformed), importsRemaining) : null;
return transformed ? _objectSpread(_objectSpread({}, scopesTransformed), scopesRemaining) : null;
};

@@ -684,12 +684,12 @@

var sortImports = function sortImports(imports) {
var importsSorted = {};
var mappingsSorted = {};
Object.keys(imports).sort(compareLengthOrLocaleCompare).forEach(function (name) {
importsSorted[name] = imports[name];
mappingsSorted[name] = imports[name];
});
return importsSorted;
return mappingsSorted;
};
var sortScopes = function sortScopes(scopes) {
var scopesSorted = {};
Object.keys(scopes).sort(compareLengthOrLocaleCompare).forEach(function (scopeName) {
scopesSorted[scopeName] = sortImports(scopes[scopeName]);
Object.keys(scopes).sort(compareLengthOrLocaleCompare).forEach(function (scopeSpecifier) {
scopesSorted[scopeSpecifier] = sortImports(scopes[scopeSpecifier]);
});

@@ -715,3 +715,3 @@ return scopesSorted;

return {
imports: imports ? normalizeImports(imports, baseUrl) : undefined,
imports: imports ? normalizeMappings(imports, baseUrl) : undefined,
scopes: scopes ? normalizeScopes(scopes, baseUrl) : undefined

@@ -721,6 +721,6 @@ };

var normalizeImports = function normalizeImports(imports, baseUrl) {
var importsNormalized = {};
Object.keys(imports).forEach(function (specifier) {
var address = imports[specifier];
var normalizeMappings = function normalizeMappings(mappings, baseUrl) {
var mappingsNormalized = {};
Object.keys(mappings).forEach(function (specifier) {
var address = mappings[specifier];

@@ -756,5 +756,5 @@ if (typeof address !== "string") {

importsNormalized[specifierResolved] = addressUrl;
mappingsNormalized[specifierResolved] = addressUrl;
});
return sortImports(importsNormalized);
return sortImports(mappingsNormalized);
};

@@ -764,9 +764,9 @@

var scopesNormalized = {};
Object.keys(scopes).forEach(function (scope) {
var scopeValue = scopes[scope];
var scopeUrl = tryUrlResolution(scope, baseUrl);
Object.keys(scopes).forEach(function (scopeSpecifier) {
var scopeMappings = scopes[scopeSpecifier];
var scopeUrl = tryUrlResolution(scopeSpecifier, baseUrl);
if (scopeUrl === null) {
console.warn(formulateScopeResolutionFailed({
scope: scope,
scope: scopeSpecifier,
baseUrl: baseUrl

@@ -777,3 +777,3 @@ }));

var scopeValueNormalized = normalizeImports(scopeValue, baseUrl);
var scopeValueNormalized = normalizeMappings(scopeMappings, baseUrl);
scopesNormalized[scopeUrl] = scopeValueNormalized;

@@ -780,0 +780,0 @@ });

{
"name": "@jsenv/import-map",
"version": "6.11.0",
"version": "6.11.1",
"description": "Helpers to implement importmaps.",

@@ -14,3 +14,4 @@ "license": "MIT",

"publishConfig": {
"access": "public"
"access": "public",
"registry": "https://registry.npmjs.org"
},

@@ -17,0 +18,0 @@ "type": "module",

@@ -21,5 +21,6 @@ # import-map

`@jsenv/import-map` can be used to implement the behaviour of importmap as described in the specification. It is written using es modules and compatible with browsers and Node.js.
`@jsenv/import-map` can be used to implement the behaviour of importmap as described in the specification. It is written using es modules and compatible with browsers and Node.js. For instance, this repository is used to make ESLint compatible with importmaps.
— see [importMap spec](https://github.com/WICG/import-maps)
- [jsenv-importmap-eslint-resolver](https://github.com/jsenv/jsenv-importmap-eslint-resolver): ESLint plugin for importmaps
- [import maps spec](https://github.com/WICG/import-maps): WICG specs about import maps on GitHub

@@ -26,0 +27,0 @@ # Installation

@@ -48,10 +48,10 @@ import { createDetailedMessage } from "@jsenv/logger"

if (scopes && importer) {
const scopeKeyMatching = Object.keys(scopes).find((scopeKey) => {
return scopeKey === importer || specifierIsPrefixOf(scopeKey, importer)
const scopeSpecifierMatching = Object.keys(scopes).find((scopeSpecifier) => {
return scopeSpecifier === importer || specifierIsPrefixOf(scopeSpecifier, importer)
})
if (scopeKeyMatching) {
const scopeValue = scopes[scopeKeyMatching]
const remappingFromScopeImports = applyImports(specifierNormalized, scopeValue)
if (remappingFromScopeImports !== null) {
return remappingFromScopeImports
if (scopeSpecifierMatching) {
const scopeMappings = scopes[scopeSpecifierMatching]
const mappingFromScopes = applyMappings(scopeMappings, specifierNormalized)
if (mappingFromScopes !== null) {
return mappingFromScopes
}

@@ -63,5 +63,5 @@ }

if (imports) {
const remappingFromImports = applyImports(specifierNormalized, imports)
if (remappingFromImports !== null) {
return remappingFromImports
const mappingFromImports = applyMappings(imports, specifierNormalized)
if (mappingFromImports !== null) {
return mappingFromImports
}

@@ -74,21 +74,20 @@ }

throw new Error(createBareSpecifierError({ specifier, importer }))
throw createBareSpecifierError({ specifier, importer })
}
const applyImports = (specifier, imports) => {
const importKeyArray = Object.keys(imports)
const applyMappings = (mappings, specifier) => {
const specifierCandidates = Object.keys(mappings)
let i = 0
while (i < importKeyArray.length) {
const importKey = importKeyArray[i]
while (i < specifierCandidates.length) {
const specifierCandidate = specifierCandidates[i]
i++
if (importKey === specifier) {
const importValue = imports[importKey]
return importValue
if (specifierCandidate === specifier) {
const address = mappings[specifierCandidate]
return address
}
if (specifierIsPrefixOf(importKey, specifier)) {
const importValue = imports[importKey]
const afterImportKey = specifier.slice(importKey.length)
return tryUrlResolution(afterImportKey, importValue)
if (specifierIsPrefixOf(specifierCandidate, specifier)) {
const address = mappings[specifierCandidate]
const afterSpecifier = specifier.slice(specifierCandidate.length)
return tryUrlResolution(afterSpecifier, address)
}

@@ -95,0 +94,0 @@ }

@@ -16,3 +16,3 @@ // https://github.com/systemjs/systemjs/blob/89391f92dfeac33919b0223bbf834a1f4eea5750/src/common.js#L136

if (leftHasImports && rightHasImports) {
importMap.imports = composeTwoImports(leftImports, rightImports)
importMap.imports = composeTwoMappings(leftImports, rightImports)
} else if (leftHasImports) {

@@ -39,21 +39,22 @@ importMap.imports = { ...leftImports }

const composeTwoImports = (leftImports, rightImports) => {
const topLevelMappings = {}
Object.keys(leftImports).forEach((leftSpecifier) => {
if (objectHasKey(rightImports, leftSpecifier)) {
const composeTwoMappings = (leftMappings, rightMappings) => {
const mappings = {}
Object.keys(leftMappings).forEach((leftSpecifier) => {
if (objectHasKey(rightMappings, leftSpecifier)) {
// will be overidden
return
}
const leftAddress = leftImports[leftSpecifier]
const rightSpecifier = Object.keys(rightImports).find((rightSpecifier) => {
const leftAddress = leftMappings[leftSpecifier]
const rightSpecifier = Object.keys(rightMappings).find((rightSpecifier) => {
return compareAddressAndSpecifier(leftAddress, rightSpecifier)
})
topLevelMappings[leftSpecifier] = rightSpecifier ? rightImports[rightSpecifier] : leftAddress
mappings[leftSpecifier] = rightSpecifier ? rightMappings[rightSpecifier] : leftAddress
})
Object.keys(rightImports).forEach((rightSpecifier) => {
topLevelMappings[rightSpecifier] = rightImports[rightSpecifier]
Object.keys(rightMappings).forEach((rightSpecifier) => {
mappings[rightSpecifier] = rightMappings[rightSpecifier]
})
return topLevelMappings
return mappings
}

@@ -69,17 +70,18 @@

const composeTwoScopes = (leftScopes, rightScopes, topLevelRemappings) => {
const scopedRemappings = {}
const composeTwoScopes = (leftScopes, rightScopes, imports) => {
const scopes = {}
Object.keys(leftScopes).forEach((leftScopeKey) => {
if (objectHasKey(rightScopes, leftScopeKey)) {
// will be merged
scopedRemappings[leftScopeKey] = leftScopes[leftScopeKey]
scopes[leftScopeKey] = leftScopes[leftScopeKey]
return
}
const topLevelSpecifier = Object.keys(topLevelRemappings).find((topLevelSpecifierCandidate) => {
const topLevelSpecifier = Object.keys(imports).find((topLevelSpecifierCandidate) => {
return compareAddressAndSpecifier(leftScopeKey, topLevelSpecifierCandidate)
})
if (topLevelSpecifier) {
scopedRemappings[topLevelRemappings[topLevelSpecifier]] = leftScopes[leftScopeKey]
scopes[imports[topLevelSpecifier]] = leftScopes[leftScopeKey]
} else {
scopedRemappings[leftScopeKey] = leftScopes[leftScopeKey]
scopes[leftScopeKey] = leftScopes[leftScopeKey]
}

@@ -89,9 +91,6 @@ })

Object.keys(rightScopes).forEach((rightScopeKey) => {
if (objectHasKey(scopedRemappings, rightScopeKey)) {
scopedRemappings[rightScopeKey] = composeTwoImports(
scopedRemappings[rightScopeKey],
rightScopes[rightScopeKey],
)
if (objectHasKey(scopes, rightScopeKey)) {
scopes[rightScopeKey] = composeTwoMappings(scopes[rightScopeKey], rightScopes[rightScopeKey])
} else {
scopedRemappings[rightScopeKey] = {
scopes[rightScopeKey] = {
...rightScopes[rightScopeKey],

@@ -101,3 +100,4 @@ }

})
return scopedRemappings
return scopes
}

@@ -38,3 +38,3 @@ import { assertImportMap } from "./internal/assertImportMap.js"

if (imports) {
importMapRelative.imports = makeImportsRelativeTo(imports, makeRelativeTo) || imports
importMapRelative.imports = makeMappingsRelativeTo(imports, makeRelativeTo) || imports
}

@@ -44,3 +44,3 @@

if (scopes) {
importMapRelative.scopes = makeScopedRemappingRelativeTo(scopes, makeRelativeTo) || scopes
importMapRelative.scopes = makeScopesRelativeTo(scopes, makeRelativeTo) || scopes
}

@@ -55,44 +55,44 @@

const makeScopedRemappingRelativeTo = (scopes, makeRelativeTo) => {
const scopesTransformed = {}
const scopesRemaining = {}
const makeMappingsRelativeTo = (mappings, makeRelativeTo) => {
const mappingsTransformed = {}
const mappingsRemaining = {}
let transformed = false
Object.keys(scopes).forEach((scopeKey) => {
const scopeValue = scopes[scopeKey]
const scopeKeyRelative = makeRelativeTo(scopeKey, "address")
const scopeValueRelative = makeImportsRelativeTo(scopeValue, makeRelativeTo)
Object.keys(mappings).forEach((specifier) => {
const address = mappings[specifier]
const specifierRelative = makeRelativeTo(specifier, "specifier")
const addressRelative = makeRelativeTo(address, "address")
if (scopeKeyRelative) {
if (specifierRelative) {
transformed = true
scopesTransformed[scopeKeyRelative] = scopeValueRelative || scopeValue
} else if (scopeValueRelative) {
mappingsTransformed[specifierRelative] = addressRelative || address
} else if (addressRelative) {
transformed = true
scopesTransformed[scopeKey] = scopeValueRelative
mappingsTransformed[specifier] = addressRelative
} else {
scopesRemaining[scopeKey] = scopeValueRelative
mappingsRemaining[specifier] = address
}
})
return transformed ? { ...scopesTransformed, ...scopesRemaining } : null
return transformed ? { ...mappingsTransformed, ...mappingsRemaining } : null
}
const makeImportsRelativeTo = (imports, makeRelativeTo) => {
const importsTransformed = {}
const importsRemaining = {}
const makeScopesRelativeTo = (scopes, makeRelativeTo) => {
const scopesTransformed = {}
const scopesRemaining = {}
let transformed = false
Object.keys(imports).forEach((importKey) => {
const importValue = imports[importKey]
const importKeyRelative = makeRelativeTo(importKey, "specifier")
const importValueRelative = makeRelativeTo(importValue, "address")
Object.keys(scopes).forEach((scopeSpecifier) => {
const scopeMappings = scopes[scopeSpecifier]
const scopeSpecifierRelative = makeRelativeTo(scopeSpecifier, "address")
const scopeMappingsRelative = makeMappingsRelativeTo(scopeMappings, makeRelativeTo)
if (importKeyRelative) {
if (scopeSpecifierRelative) {
transformed = true
importsTransformed[importKeyRelative] = importValueRelative || importValue
} else if (importValueRelative) {
scopesTransformed[scopeSpecifierRelative] = scopeMappingsRelative || scopeMappings
} else if (scopeMappingsRelative) {
transformed = true
importsTransformed[importKey] = importValueRelative
scopesTransformed[scopeSpecifier] = scopeMappingsRelative
} else {
importsRemaining[importKey] = importValue
scopesRemaining[scopeSpecifier] = scopeMappingsRelative
}
})
return transformed ? { ...importsTransformed, ...importsRemaining } : null
return transformed ? { ...scopesTransformed, ...scopesRemaining } : null
}

@@ -15,3 +15,3 @@ import { assertImportMap } from "./internal/assertImportMap.js"

return {
imports: imports ? normalizeImports(imports, baseUrl) : undefined,
imports: imports ? normalizeMappings(imports, baseUrl) : undefined,
scopes: scopes ? normalizeScopes(scopes, baseUrl) : undefined,

@@ -21,7 +21,8 @@ }

const normalizeImports = (imports, baseUrl) => {
const importsNormalized = {}
Object.keys(imports).forEach((specifier) => {
const address = imports[specifier]
const normalizeMappings = (mappings, baseUrl) => {
const mappingsNormalized = {}
Object.keys(mappings).forEach((specifier) => {
const address = mappings[specifier]
if (typeof address !== "string") {

@@ -61,5 +62,6 @@ console.warn(

}
importsNormalized[specifierResolved] = addressUrl
mappingsNormalized[specifierResolved] = addressUrl
})
return sortImports(importsNormalized)
return sortImports(mappingsNormalized)
}

@@ -69,9 +71,10 @@

const scopesNormalized = {}
Object.keys(scopes).forEach((scope) => {
const scopeValue = scopes[scope]
const scopeUrl = tryUrlResolution(scope, baseUrl)
Object.keys(scopes).forEach((scopeSpecifier) => {
const scopeMappings = scopes[scopeSpecifier]
const scopeUrl = tryUrlResolution(scopeSpecifier, baseUrl)
if (scopeUrl === null) {
console.warn(
formulateScopeResolutionFailed({
scope,
scope: scopeSpecifier,
baseUrl,

@@ -82,5 +85,6 @@ }),

}
const scopeValueNormalized = normalizeImports(scopeValue, baseUrl)
const scopeValueNormalized = normalizeMappings(scopeMappings, baseUrl)
scopesNormalized[scopeUrl] = scopeValueNormalized
})
return sortScopes(scopesNormalized)

@@ -87,0 +91,0 @@ }

@@ -15,9 +15,11 @@ import { assertImportMap } from "./internal/assertImportMap.js"

export const sortImports = (imports) => {
const importsSorted = {}
const mappingsSorted = {}
Object.keys(imports)
.sort(compareLengthOrLocaleCompare)
.forEach((name) => {
importsSorted[name] = imports[name]
mappingsSorted[name] = imports[name]
})
return importsSorted
return mappingsSorted
}

@@ -27,7 +29,9 @@

const scopesSorted = {}
Object.keys(scopes)
.sort(compareLengthOrLocaleCompare)
.forEach((scopeName) => {
scopesSorted[scopeName] = sortImports(scopes[scopeName])
.forEach((scopeSpecifier) => {
scopesSorted[scopeSpecifier] = sortImports(scopes[scopeSpecifier])
})
return scopesSorted

@@ -34,0 +38,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc