jsenv-module-resolution
The following code illustrates what import this project aims to resolve.
import "https://domai.com:80/file.js"
import "//file.js"
import "/root.js"
import "./beside.js"
import "./folder/below.js"
import "../above.js"
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