Socket
Socket
Sign inDemoInstall

@jsenv/module-resolution

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/module-resolution

[![npm package](https://img.shields.io/npm/v/@jsenv/module-resolution.svg)](https://www.npmjs.com/package/@jsenv/module-resolution) [![build](https://travis-ci.com/jsenv/jsenv-module-resolution.svg?branch=master)](http://travis-ci.com/jsenv/jsenv-module-r


Version published
Weekly downloads
19
Maintainers
2
Weekly downloads
 
Created
Source

jsenv module resolution

npm package build codecov

import resolution and remapping.

Introduction

This module exports a resolvePath you can use to resolve an import.
It is used by jsenv to find every import statement files.

Installation

npm install @jsenv/module-resolution

resolvePath

takes { specifier, importer, importMap, defaultExtension } and returns a resolved path.

basic example
import { resolvePath } from "@jsenv/module-resolution"

const resolvePath = resolveImport({
  importer: "http://domain.com/folder/file.js",
  specifier: "../index.js",
})

console.log(resolvePath)

The code above logs http://domain.com/index.js.

remapping example
import { resolvePath } from "@jsenv/module-resolution"

const resolvedPath = resolvePath({
  importer: "http://domain.com/folder/file.js",
  specifier: "../index.js",
  importMap: {
    imports: {
      "/index.js": "/foo.js",
    },
  },
})

console.log(resolvedPath)

code above logs http://domain.com/foo.js.

scoped remapping example
import { resolvedPath } from "@jsenv/module-resolution"

const resolvedPath = resolvePath({
  importer: "http://domain.com/folder/file.js",
  specifier: "../index.js",
  importMap: {
    imports: {
      "/index.js": "/foo.js",
    },
    scopes: {
      "/folder/": {
        "/index.js": "/bar.js",
      },
    },
  },
})

console.log(remappedImport)

code above logs http://domain.com/bar.js.

FAQs

Package last updated on 02 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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