https://github.com/shigma/ns-require
Require with Namespace
https://github.com/shigma/ns-require
Last synced: 29 days ago
JSON representation
Require with Namespace
- Host: GitHub
- URL: https://github.com/shigma/ns-require
- Owner: shigma
- License: mit
- Created: 2022-04-21T06:18:23.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-30T15:51:17.000Z (about 2 years ago)
- Last Synced: 2025-04-19T20:44:20.134Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 13.7 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ns-require
[](https://codecov.io/gh/shigma/ns-require)
[](https://www.npmjs.com/package/ns-require)
[](https://www.npmjs.com/package/ns-require)
[](https://github.com/shigma/ns-require/blob/master/LICENSE)Require with Namespace.
## Basic Usage
```ts
import ns from 'ns-require'const scope = ns({
namespace: 'awesome',
prefix: 'plugin',
})scope.require('foo') // will resolve to `awesome-plugin-foo`
scope.require('@foo/bar') // will resolve to `@foo/awesome-plugin-bar`
```## With Official Scope
```ts
import ns from 'ns-require'const scope = ns({
namespace: 'awesome',
prefix: 'plugin',
official: 'scope',
})scope.require('foo') // will resolve to `@scope/plugin-foo`
// and then `awesome-plugin-foo`
scope.require('@foo/bar') // will resolve to `@foo/awesome-plugin-bar`
```