Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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 2 months ago
JSON representation

Dependency injection to register module to global access, you can load each given module from kraken config

Awesome Lists containing this project

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)


BACK TO TOP