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.7.4 to 6.8.0

src/makeImportMapRelativeTo.js

124

dist/esmodule/main.js

@@ -397,3 +397,3 @@ var nativeTypeOf = function nativeTypeOf(obj) {

var rightImports = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return _objectSpread({}, leftImports, {}, rightImports);
return _objectSpread(_objectSpread({}, leftImports), rightImports);
};

@@ -409,3 +409,3 @@

if (scopes.hasOwnProperty(scopeKey)) {
scopes[scopeKey] = _objectSpread({}, scopes[scopeKey], {}, rightScopes[scopeKey]);
scopes[scopeKey] = _objectSpread(_objectSpread({}, scopes[scopeKey]), rightScopes[scopeKey]);
} else {

@@ -418,2 +418,120 @@ scopes[scopeKey] = _objectSpread({}, rightScopes[scopeKey]);

var makeImportMapRelativeTo = function makeImportMapRelativeTo(importMap, url) {
assertImportMap(importMap);
var slashCount = urlToPathname(url).slice(1).split("/").length - 1;
if (slashCount === 0) {
return importMap;
}
var importMapRelative = {};
var imports = importMap.imports;
if (imports) {
importMapRelative.imports = makeImportsRelativeTo(imports, url) || imports;
}
var scopes = importMap.scopes;
if (scopes) {
importMapRelative.scopes = makeScopedRemappingRelativeTo(scopes, url) || scopes;
}
return importMapRelative;
};
var makeScopedRemappingRelativeTo = function makeScopedRemappingRelativeTo(scopes, url) {
var scopesTransformed = {};
var scopesRemaining = {};
var transformed = false;
Object.keys(scopes).forEach(function (scopeKey) {
var scopeValue = scopes[scopeKey];
var scopeKeyRelative = makeAddressRelativeTo(scopeKey, url);
var scopeValueRelative = makeImportsRelativeTo(scopeValue, url);
if (scopeKeyRelative) {
transformed = true;
scopesTransformed[scopeKeyRelative] = scopeValueRelative || scopeValue;
} else if (scopeValueRelative) {
transformed = true;
scopesTransformed[scopeKey] = scopeValueRelative;
} else {
scopesRemaining[scopeKey] = scopeValueRelative;
}
});
return transformed ? _objectSpread(_objectSpread({}, scopesTransformed), scopesRemaining) : null;
};
var makeImportsRelativeTo = function makeImportsRelativeTo(imports, url) {
var importsTransformed = {};
var importsRemaining = {};
var transformed = false;
Object.keys(imports).forEach(function (importKey) {
var importValue = imports[importKey];
var importKeyRelative = makeSpecifierRelativeTo(importKey, url);
var importValueRelative = makeAddressRelativeTo(importValue, url);
if (importKeyRelative) {
transformed = true;
importsTransformed[importKeyRelative] = importValueRelative || importValue;
} else if (importValueRelative) {
transformed = true;
importsTransformed[importKey] = importValueRelative;
} else {
importsRemaining[importKey] = importValue;
}
});
return transformed ? _objectSpread(_objectSpread({}, importsTransformed), importsRemaining) : null;
};
var makeSpecifierRelativeTo = function makeSpecifierRelativeTo(specifier, url) {
if (specifier.startsWith("//")) {
return null;
}
if (specifier[0] === "/") {
return null;
}
if (specifier.startsWith("./")) {
return makeRelativeTo(specifier.slice(2), url);
}
if (specifier.startsWith("../")) {
return makeRelativeTo(specifier, url);
}
return null;
};
var makeAddressRelativeTo = function makeAddressRelativeTo(address, url) {
if (address.startsWith("//")) {
return null;
}
if (address[0] === "/") {
return null;
}
if (address.startsWith("./")) {
return makeRelativeTo(address.slice(2), url);
}
if (address.startsWith("../")) {
return makeRelativeTo(address, url);
}
if (hasScheme(address)) {
return null;
} // bare
return makeRelativeTo(address, url);
};
var makeRelativeTo = function makeRelativeTo(string, url) {
var slashCount = urlToPathname(url).slice(1).split("/").length - 1;
return "".concat("../".repeat(slashCount)).concat(string);
};
var sortImportMap = function sortImportMap(importMap) {

@@ -616,3 +734,3 @@ assertImportMap(importMap);

export { applyImportMap, composeTwoImportMaps, normalizeImportMap, resolveImport, resolveSpecifier, resolveUrl, sortImportMap };
export { applyImportMap, composeTwoImportMaps, makeImportMapRelativeTo, normalizeImportMap, resolveImport, resolveSpecifier, resolveUrl, sortImportMap };
//# sourceMappingURL=main.js.map
export { applyImportMap } from "./src/applyImportMap.js"
export { composeTwoImportMaps } from "./src/composeTwoImportMaps.js"
export { makeImportMapRelativeTo } from "./src/makeImportMapRelativeTo.js"
export { normalizeImportMap } from "./src/normalizeImportMap.js"

@@ -4,0 +5,0 @@ export { resolveImport } from "./src/resolveImport.js"

35

package.json
{
"name": "@jsenv/import-map",
"version": "6.7.4",
"version": "6.8.0",
"description": "Helpers to implement importmaps.",

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

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

@@ -34,3 +33,3 @@ "type": "module",

"start-exploring": "node --no-warnings ./script/start-exploring/start-exploring.js",
"test": "node --no-warnings ./script/test/test.js",
"test": "node --no-warnings --unhandled-rejections=strict ./script/test/test.js",
"test-with-coverage": "npm run test -- --coverage",

@@ -45,27 +44,23 @@ "eslint-check": "node ./node_modules/eslint/bin/eslint.js .",

"generate-import-map": "node --no-warnings ./script/generate-import-map/generate-import-map.js",
"install-git-hooks": "node --no-warnings ./script/install-git-hooks/install-git-hooks.js",
"dist": "npm run generate-esmodule-bundle && npm run generate-commonjs-bundle",
"prepublishOnly": "node ./script/transform-package/remove-postinstall.js && npm run dist",
"postpublish": "node ./script/transform-package/restore-postinstall.js",
"git-hook-pre-commit": "npm run prettier-format-stage"
"postpublish": "node ./script/transform-package/restore-postinstall.js"
},
"dependencies": {},
"devDependencies": {
"@jsenv/assert": "2.1.0",
"@jsenv/codecov-upload": "3.4.0",
"@jsenv/core": "13.0.0-alpha.3",
"@jsenv/eslint-config": "12.4.1",
"@jsenv/git-hooks": "1.3.3",
"@jsenv/assert": "2.2.1",
"@jsenv/codecov-upload": "3.4.2",
"@jsenv/core": "15.0.3",
"@jsenv/eslint-config": "12.5.0",
"@jsenv/github-release-package": "1.2.2",
"@jsenv/node-module-import-map": "12.0.2",
"@jsenv/package-publish": "1.5.1",
"@jsenv/node-module-import-map": "11.1.1",
"@jsenv/prettier-check-project": "5.6.0",
"@jsenv/prettier-config": "1.2.0",
"@jsenv/prettier-check-project": "5.6.1",
"babel-eslint": "11.0.0-beta.0",
"eslint": "6.8.0",
"playwright-chromium": "0.11.1",
"playwright-firefox": "0.11.1",
"playwright-webkit": "0.11.1",
"prettier": "2.0.5"
"eslint": "7.10.0",
"playwright-chromium": "1.4.2",
"playwright-firefox": "1.4.2",
"playwright-webkit": "1.4.2",
"prettier": "2.1.2"
}
}

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