This package has been deprecated

Author message:

Renamed to @make-mjs/url

@make-mjs/path
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@make-mjs/path

Manipulate MJS module path

Examples

Internal Modules

import getMjsPath from '@make-mjs/path'

const mjsPath: string = await getMjsPath({
  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.
  • If ./foo/bar/baz does not point to a directory, mjsPath would be ./foo/bar/baz.mjs.
  • For other cases, read the tests.

External Modules

import getMjsPath from '@make-mjs/path'

const mjsPath: string = await getMjsPath({
  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.
  • If node_modules/foo/bar/baz points to a directory that contains a package.json that have "module" points to module.mjs, mjsPath would be foo/bar/baz/module.mjs.
  • If node_modules/foo/baz.js points to a file, mjsPath would be foo/bar/baz.mjs.
  • For other cases, read the tests.

License

MIT © Hoàng Văn Khải

Readme

Keywords

none

Package Sidebar

Install

npm i @make-mjs/path

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

30.7 kB

Total Files

46

Last publish

Collaborators

  • khai96_