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.1 to 6.12.0

40

dist/esmodule/main.js

@@ -232,3 +232,5 @@ var createDetailedMessage = function createDetailedMessage(message) {

}));
} : _ref$createBareSpecif;
} : _ref$createBareSpecif,
_ref$onImportMapping = _ref.onImportMapping,
onImportMapping = _ref$onImportMapping === void 0 ? function () {} : _ref$onImportMapping;
assertImportMap(importMap);

@@ -270,3 +272,3 @@

var scopeMappings = scopes[scopeSpecifierMatching];
var mappingFromScopes = applyMappings(scopeMappings, specifierNormalized);
var mappingFromScopes = applyMappings(scopeMappings, specifierNormalized, scopeSpecifierMatching, onImportMapping);

@@ -282,3 +284,3 @@ if (mappingFromScopes !== null) {

if (imports) {
var mappingFromImports = applyMappings(imports, specifierNormalized);
var mappingFromImports = applyMappings(imports, specifierNormalized, undefined, onImportMapping);

@@ -300,3 +302,3 @@ if (mappingFromImports !== null) {

var applyMappings = function applyMappings(mappings, specifier) {
var applyMappings = function applyMappings(mappings, specifierNormalized, scope, onImportMapping) {
var specifierCandidates = Object.keys(mappings);

@@ -309,11 +311,26 @@ var i = 0;

if (specifierCandidate === specifier) {
if (specifierCandidate === specifierNormalized) {
var address = mappings[specifierCandidate];
onImportMapping({
scope: scope,
from: specifierCandidate,
to: address,
before: specifierNormalized,
after: address
});
return address;
}
if (specifierIsPrefixOf(specifierCandidate, specifier)) {
if (specifierIsPrefixOf(specifierCandidate, specifierNormalized)) {
var _address = mappings[specifierCandidate];
var afterSpecifier = specifier.slice(specifierCandidate.length);
return tryUrlResolution(afterSpecifier, _address);
var afterSpecifier = specifierNormalized.slice(specifierCandidate.length);
var addressFinal = tryUrlResolution(afterSpecifier, _address);
onImportMapping({
scope: scope,
from: specifierCandidate,
to: _address,
before: specifierNormalized,
after: addressFinal
});
return addressFinal;
}

@@ -822,3 +839,5 @@ }

defaultExtension = _ref$defaultExtension === void 0 ? true : _ref$defaultExtension,
createBareSpecifierError = _ref.createBareSpecifierError;
createBareSpecifierError = _ref.createBareSpecifierError,
_ref$onImportMapping = _ref.onImportMapping,
onImportMapping = _ref$onImportMapping === void 0 ? function () {} : _ref$onImportMapping;
return applyDefaultExtension({

@@ -829,3 +848,4 @@ url: importMap ? applyImportMap({

importer: importer,
createBareSpecifierError: createBareSpecifierError
createBareSpecifierError: createBareSpecifierError,
onImportMapping: onImportMapping
}) : resolveUrl(specifier, importer),

@@ -832,0 +852,0 @@ importer: importer,

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

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

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

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

@@ -21,7 +21,4 @@ # 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. For instance, this repository is used to make ESLint compatible with importmaps.
`@jsenv/import-map` can be used to implement the behaviour of importmap as described in the [WICG specification](https://github.com/WICG/import-maps). It is written using ES modules and compatible with browsers and Node.js. Amongst other things, this repository is used to provide [importmap in ESLint](https://github.com/jsenv/jsenv-importmap-eslint-resolver).
- [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
# Installation

@@ -28,0 +25,0 @@

@@ -14,2 +14,3 @@ import { createDetailedMessage } from "@jsenv/logger"

},
onImportMapping = () => {},
}) => {

@@ -54,3 +55,8 @@ assertImportMap(importMap)

const scopeMappings = scopes[scopeSpecifierMatching]
const mappingFromScopes = applyMappings(scopeMappings, specifierNormalized)
const mappingFromScopes = applyMappings(
scopeMappings,
specifierNormalized,
scopeSpecifierMatching,
onImportMapping,
)
if (mappingFromScopes !== null) {

@@ -64,3 +70,8 @@ return mappingFromScopes

if (imports) {
const mappingFromImports = applyMappings(imports, specifierNormalized)
const mappingFromImports = applyMappings(
imports,
specifierNormalized,
undefined,
onImportMapping,
)
if (mappingFromImports !== null) {

@@ -78,3 +89,3 @@ return mappingFromImports

const applyMappings = (mappings, specifier) => {
const applyMappings = (mappings, specifierNormalized, scope, onImportMapping) => {
const specifierCandidates = Object.keys(mappings)

@@ -86,10 +97,25 @@

i++
if (specifierCandidate === specifier) {
if (specifierCandidate === specifierNormalized) {
const address = mappings[specifierCandidate]
onImportMapping({
scope,
from: specifierCandidate,
to: address,
before: specifierNormalized,
after: address,
})
return address
}
if (specifierIsPrefixOf(specifierCandidate, specifier)) {
if (specifierIsPrefixOf(specifierCandidate, specifierNormalized)) {
const address = mappings[specifierCandidate]
const afterSpecifier = specifier.slice(specifierCandidate.length)
return tryUrlResolution(afterSpecifier, address)
const afterSpecifier = specifierNormalized.slice(specifierCandidate.length)
const addressFinal = tryUrlResolution(afterSpecifier, address)
onImportMapping({
scope,
from: specifierCandidate,
to: address,
before: specifierNormalized,
after: addressFinal,
})
return addressFinal
}

@@ -96,0 +122,0 @@ }

@@ -12,6 +12,13 @@ import { urlToPathname } from "./internal/urlToPathname.js"

createBareSpecifierError,
onImportMapping = () => {},
}) => {
return applyDefaultExtension({
url: importMap
? applyImportMap({ importMap, specifier, importer, createBareSpecifierError })
? applyImportMap({
importMap,
specifier,
importer,
createBareSpecifierError,
onImportMapping,
})
: resolveUrl(specifier, importer),

@@ -18,0 +25,0 @@ importer,

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