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

@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

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-90%
Maintainers
2
Weekly downloads
 
Created
Source

jsenv-module-resolution

npm package build codecov

The following code illustrates what import this project aims to resolve.

// absolute
import "https://domai.com:80/file.js"
// protocol relative
import "//file.js"
// origin relative
import "/root.js"
// pathname relative beside
import "./beside.js"
// pathname relative below
import "./folder/below.js"
// pathname relative above
import "../above.js"
// bare
import "fs"

This project exports a resolveImport function capable to resolve these imports.

resolveImport

Check test folder to understand how this function works.

Bare import

Here are some examples of bar imports: import "fs", import "lodash" or import "@babel/core".

Inside a browser bare specifier will be explicitely reserved. This way third party module will not clash with future browser native modules.

Inside node, node module resolution algorithm find the corresponding file for you. It means node native module and third party module look the same.

For that reason, it would be future proof to replace bare import like this:

import "fs" -> import "fs" (unchanged)

import "lodash" -> import "/node_modules/lodash/index.js"

import "@babel/core" -> import "/node_modules/@babel/core/index.js"

Installing

npm i github:jsenv/module-resolution

FAQs

Package last updated on 29 Mar 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