Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bem-react/di

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bem-react/di - npm Package Compare versions

Comparing version 1.6.0 to 2.0.0

build/di.development.js

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [2.0.0](https://github.com/bem/bem-react/tree/master/packages/di/compare/@bem-react/di@1.6.0...@bem-react/di@2.0.0) (2019-05-24)
### Features
* **di:** replace inverted by overridable ([957a0fe](https://github.com/bem/bem-react/tree/master/packages/di/commit/957a0fe))
### BREAKING CHANGES
* **di:** Set inverted flag by default and rename it to "overridable".
# [1.6.0](https://github.com/bem/bem-react/tree/master/packages/di/compare/@bem-react/di@1.5.3...@bem-react/di@1.6.0) (2019-04-22)

@@ -8,0 +24,0 @@

6

di.d.ts

@@ -15,9 +15,9 @@ import React, { ReactNode, FunctionComponent, ComponentType } from 'react';

id: string;
inverted?: boolean;
overridable?: boolean;
}
export declare class Registry {
id: string;
inverted: boolean;
overridable: boolean;
private components;
constructor({ id, inverted }: IRegistryOptions);
constructor({ id, overridable }: IRegistryOptions);
/**

@@ -24,0 +24,0 @@ * Set react component in registry by id.

'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./build/cjs/di.production.min.js');
module.exports = require('./build/di.production.min.js');
} else {
module.exports = require('./build/cjs/di.development.js');
module.exports = require('./build/di.development.js');
}
{
"name": "@bem-react/di",
"version": "1.6.0",
"version": "2.0.0",
"description": "BEM React Dependency Injection",

@@ -27,3 +27,3 @@ "homepage": "https://github.com/bem/bem-react",

"prepublishOnly": "npm run build",
"build": "PKG=di node ../../scripts/rollup/build.js",
"build": "node ../../scripts/rollup/build.js",
"lint": "__DEV__=1 tsc -p . --noEmit && tslint -p . -t stylish",

@@ -52,3 +52,3 @@ "unit": "../../node_modules/.bin/mocha --opts ../../mocha.opts --",

},
"gitHead": "f542664df66df1874065280f8ff52f74cb2663a4"
"gitHead": "b2939f6e269850d7147889f2632fa6ed3fc1f7b4"
}

@@ -1,2 +0,2 @@

# Dependency Injection (DI)
# @bem-react/di · [![npm (scoped)](https://img.shields.io/npm/v/@bem-react/di.svg)](https://www.npmjs.com/package/@bem-react/di) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/@bem-react/di.svg)](https://bundlephobia.com/result?p=@bem-react/di)

@@ -12,3 +12,3 @@ **Dependency Injection (DI)** allows you to split React components into separate versions and comfortably switch them in the project whenever needed, e.g., to make a specific bundle.

```
npm i @bem-react/di -S
npm i -S @bem-react/di
```

@@ -170,1 +170,28 @@

```
## Replacing components
Components inside registry can be replaced (e.g. for experiments) by wrapping `withRegistry(...)(App)` with another registry.
```ts
import { Registry, withRegistry } from '@bem-react/di';
import { AppDesktop } from './App@desktop';
import { HeaderExperimental } from './experiments/Components/Header/Header';
const expRegistry = new Registry({ id: cnApp() });
// replacing original Header with HeaderExperimental
registry.set('Header', HeaderExperimental);
// AppDesktopExperimental will call App with HeaderExperimental as 'Header'
export const AppDesktopExperimental = withRegistry(expRegistry)(AppDesktop);
```
When `App` extracts components from registry *DI* actually takes all registries defined above and merges. By default higher defined registry overrides lower defined one.
If at some point you want to create registry that wan't be overrided just call the constructor with `overridable: false`.
```ts
const boldRegistry = new Registry({ id: cnApp(), overridable: false });
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc