Manipulate MJS module url
npm install @make-mjs/urlManipulate MJS module URL
Go to the GitHub page
``typescript
import getMjsUrl from '@make-mjs/url'
const mjsPath: string = await getMjsUrl({
modulePath: './foo/bar/baz', // leading '.' or '..' is required to be recognized as internal
/ ...and more options... /
})
`
Result:
* If ./foo/bar/baz points to a directory without a package.json, mjsPath would be ./foo/bar/baz/index.mjs../foo/bar/baz
* If does not point to a directory, mjsPath would be ./foo/bar/baz.mjs.
* For other cases, read the tests.
`typescript
import getMjsUrl from '@make-mjs/url'
const mjsPath: string = await getMjsUrl({
modulePath: 'foo/bar/baz',
moduleContainer: [
'node_modules'
],
/ ...and more options... /
})
`
Result:
* If node_modules/foo/bar/baz points to a directory without a package.json, mjsPath would be foo/bar/baz/index.mjs.node_modules/foo/bar/baz
* If points to a directory that contains a package.json that have "module" points to module.mjs, mjsPath would be foo/bar/baz/module.mjs.node_modules/foo/baz.js
* If points to a file, mjsPath would be foo/bar/baz.mjs`.
* For other cases, read the tests.