Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/restuwahyu13/kraken-browser
Dependency injection to register module to global access, you can load each given module from kraken config
https://github.com/restuwahyu13/kraken-browser
browser dependencies dependency-injection global global-module javascript kibrow kraken-browser node node-package npm npm-package typescript
Last synced: about 1 month ago
JSON representation
Dependency injection to register module to global access, you can load each given module from kraken config
- Host: GitHub
- URL: https://github.com/restuwahyu13/kraken-browser
- Owner: restuwahyu13
- License: mit
- Created: 2021-08-18T15:04:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-27T13:04:32.000Z (almost 2 years ago)
- Last Synced: 2024-10-28T19:13:50.133Z (about 1 month ago)
- Topics: browser, dependencies, dependency-injection, global, global-module, javascript, kibrow, kraken-browser, node, node-package, npm, npm-package, typescript
- Language: TypeScript
- Homepage:
- Size: 1 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-made-by-indonesian - Kraken Browser - `Dependency injection to register module to global access, you can load each given module from kraken config` *by [Restu Wahyu Saputra](https://github.com/restuwahyu13)* (K)
- made-in-indonesia - Kraken Browser - `Dependency injection to register module to global access, you can load each given module from kraken config` *by [Restu Wahyu Saputra](https://github.com/restuwahyu13)* (K)
README
# Kraken Browser
[![codebeat badge](https://codebeat.co/badges/7f508275-ae9e-44a8-b9c7-8e036e0f5b27)](https://codebeat.co/projects/github-com-restuwahyu13-kraken-browser-main) [![CodeFactor](https://www.codefactor.io/repository/github/restuwahyu13/kraken-browser/badge?s=764996c37a16eaf4c8c9997f166d2a76005cf811)](https://www.codefactor.io/repository/github/restuwahyu13/kraken-browser) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/14d5b6f262cb4e78a553f164f3cdf3eb)](https://www.codacy.com/gh/restuwahyu13/kraken-browser/dashboard?utm_source=github.com&utm_medium=referral&utm_content=restuwahyu13/kraken-browser&utm_campaign=Badge_Grade) ![node-current](https://img.shields.io/node/v/kibrow?style=flat-square) ![npm](https://img.shields.io/npm/dm/kibrow) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/restuwahyu13/kraken-browser/blob/main/CONTRIBUTING.md)
**kibrow** is dependency injection to register module to global access, without the need to load module using `require` or `import` again in every file, then module can be accessed as a global with very easy and then only register modules to kraken config, which you often the most used in each every file, example module like `axios`, `lodash`, `moment` etc, for nodejs version check this [kinode](https://github.com/restuwahyu13/kraken-node).
- [Kraken Browser](#kraken-browser)
- [Installation](#installation)
- [Config](#config)
- [Example Usage](#example-usage)
- [Testing](#testing)
- [Bugs](#bugs)
- [Contributing](#contributing)
- [License](#license)## Installation
```bash
$ npm install kibrow -S or yarn add kibrow -S
```## Config
- #### Kraken config property
- **name** for to calling module in each every file and default value is to undefined
- **module** for to register module to global access and default value is to undefined
- **inject** for to disabled module to global access, if value is set to false and default value is to true- #### Example Kraken Config Not With SSR
```js
import { krakenConfig } from 'kibrow'
import axios from 'axios'
import _ from 'lodash'krakenConfig({
packages: [
{
name: '$axios',
module: axios
},
{
name: '$_',
module: _
}
]
})
```- #### Example Kraken Config With SSR
```js
import { krakenConfig } from 'kibrow/ssr'
import axios from 'axios'
import _ from 'lodash'krakenConfig({
packages: [
{
name: '$axios',
module: axios
},
{
name: '$_',
module: _
}
]
})
```## Example Usage
Before usage of this module, if you're using ESLint you have must be added **Overrides ESLint Config**, and also if you're using typescript add `"noImplicitAny": false` to tsconfig.json, for more example usage and implementation check folder demo in this repository [here](https://github.com/restuwahyu13/kraken-browser/tree/main/demo).
- ##### Overrides Eslint Config
```json
"overrides": [
{
"files": [
"**/*.js",
"**/*.jsx",
"**/*.ts",
"**/*.tsx"
],
"rules": {
"no-restricted-globals": 0
},
"globals": {
"self": "writable"
}
}
]
```- ##### Example Usage Using JavaScript
```javascript
self.$axios.get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```- ##### Example Usage Using TypeScript
```javascript
self['$axios'].get('https://jsonplaceholder.typicode.com/users')
.then(res => console.log(res.data))
.catch(err => console.log(err.response.data))
```## Testing
- Testing Via Local
```sh
npm test or make test
```- Testing Via Local And Build
```sh
make build
```- Testing Via Docker
```sh
docker build -t kraken-browser or make dkb tag=kraken-browser
```## Bugs
For information on bugs related to package libraries, please visit [here](https://github.com/restuwahyu13/kraken-browser/issues)
## Contributing
Want to make **kraken-browser** more perfect ? Let's contribute and follow the [contribution guide.](https://github.com/restuwahyu13/kraken-browser/blob/main/CONTRIBUTING.md)
## License
- [MIT License](https://github.com/restuwahyu13/kraken-browser/blob/main/LICENSE.md)