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

@jsenv/eslint-import-resolver

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/eslint-import-resolver - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

dist/src/registerFileLifecycle.js

2

dist/package.json
{
"name": "@jsenv/eslint-import-resolver",
"version": "1.0.0",
"version": "2.0.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -16,4 +16,2 @@ "use strict";

var _registerFileChangeCallback = require("./registerFileChangeCallback.js");
// https://github.com/benmosher/eslint-plugin-import/blob/master/resolvers/node/index.js

@@ -24,7 +22,5 @@ // https://github.com/benmosher/eslint-plugin-import/tree/master/resolvers

exports.interfaceVersion = interfaceVersion;
let watching = false;
const resolve = (source, file, {
projectFolder,
importMapFilenameRelative = "importMap.json",
importMap = {},

@@ -47,23 +43,3 @@ origin = "http://example.com",

const filenameRelative = file.slice(projectFolder.length + 1);
const importerHref = `${origin}/${filenameRelative}`; // we accept an additional importMapFilenameRelative capable of overriding
// importMap we receive so that you don't have to restart vscode when
// importMap.json file changes
if (watching === false) {
const importMapFilename = `${projectFolder}/${importMapFilenameRelative}`;
watching = true;
(0, _registerFileChangeCallback.registerFileChangeCallback)({
filename: importMapFilename,
callback: async () => {
(0, _fs.readFile)(importMapFilename, (error, buffer) => {
if (error) {
throw error;
} else {
importMap = JSON.parse(String(buffer));
}
});
}
});
}
const importerHref = `${origin}/${filenameRelative}`;
const log = verbose ? (...args) => console.log(...args) : () => {};

@@ -95,2 +71,3 @@ log(`resolving import.

});
log(`-> located at ${resolvedImport}`);
const remappedImport = (0, _moduleResolution.remapResolvedImport)({

@@ -102,6 +79,10 @@ importMap,

const remappedOrigin = (0, _moduleResolution.hrefToOrigin)(remappedImport);
log(`-> located at ${remappedImport}`);
if (remappedOrigin === origin) {
const filename = `${projectFolder}${(0, _moduleResolution.hrefToPathname)(remappedImport)}`;
if (remappedImport !== resolvedImport) {
log(`-> remapped to ${filename}`);
}
log(`-> search file at ${filename}`);

@@ -124,2 +105,6 @@

if (remappedImport !== resolvedImport) {
log(`-> remapped to ${remappedImport}`);
}
const scheme = (0, _moduleResolution.hrefToScheme)(remappedImport);

@@ -126,0 +111,0 @@

{
"name": "@jsenv/eslint-import-resolver",
"version": "1.0.0",
"version": "2.0.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -5,3 +5,3 @@ // https://github.com/benmosher/eslint-plugin-import/blob/master/resolvers/node/index.js

import { existsSync, readFile } from "fs"
import { existsSync } from "fs"
import {

@@ -17,18 +17,9 @@ resolveImport,

import { isNativeBrowserModuleBareSpecifier } from "@jsenv/module-resolution/dist/src/isNativeBrowserModuleBareSpecifier.js"
import { registerFileChangeCallback } from "./registerFileChangeCallback.js"
export const interfaceVersion = 2
let watching = false
export const resolve = (
source,
file,
{
projectFolder,
importMapFilenameRelative = "importMap.json",
importMap = {},
origin = "http://example.com",
verbose = false,
},
{ projectFolder, importMap = {}, origin = "http://example.com", verbose = false },
) => {

@@ -51,22 +42,2 @@ projectFolder = normalizePathname(projectFolder)

// we accept an additional importMapFilenameRelative capable of overriding
// importMap we receive so that you don't have to restart vscode when
// importMap.json file changes
if (watching === false) {
const importMapFilename = `${projectFolder}/${importMapFilenameRelative}`
watching = true
registerFileChangeCallback({
filename: importMapFilename,
callback: async () => {
readFile(importMapFilename, (error, buffer) => {
if (error) {
throw error
} else {
importMap = JSON.parse(String(buffer))
}
})
},
})
}
const log = verbose ? (...args) => console.log(...args) : () => {}

@@ -93,2 +64,3 @@

})
log(`-> located at ${resolvedImport}`)

@@ -102,6 +74,8 @@ const remappedImport = remapResolvedImport({

const remappedOrigin = hrefToOrigin(remappedImport)
log(`-> located at ${remappedImport}`)
if (remappedOrigin === origin) {
const filename = `${projectFolder}${hrefToPathname(remappedImport)}`
if (remappedImport !== resolvedImport) {
log(`-> remapped to ${filename}`)
}
log(`-> search file at ${filename}`)

@@ -123,2 +97,5 @@

if (remappedImport !== resolvedImport) {
log(`-> remapped to ${remappedImport}`)
}
const scheme = hrefToScheme(remappedImport)

@@ -125,0 +102,0 @@

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