[](https://www.npmjs.com/package/@jsenv/module-resolution) [](http://travis-ci.com/jsenv/jsenv-module-r
npm install @jsenv/module-resolution


> import resolution and remapping.
This module exports a resolvePath you can use to resolve an import.
It is used by jsenv to find every import statement files.
``console`
npm install @jsenv/module-resolution
> takes { specifier, importer, importMap, defaultExtension } and returns a resolved path.
##### basic example
`js
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
`js
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
`js
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`.