# @tinkoff/shared-library-webpack-plugin

> Webpack plugin for library sharing at runtime between applications

Latest version **1.1.0** (published 2021-07-14) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @tinkoff/shared-library-webpack-plugin
pnpm add @tinkoff/shared-library-webpack-plugin
yarn add @tinkoff/shared-library-webpack-plugin
bun add @tinkoff/shared-library-webpack-plugin
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-07-14 |
| First published | 2020-06-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 76.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Igor Katsuba |
| Maintainers | alexkvak, dersizes, tinkoffbank, tom910, dmitry-korolev, rouland, ishivan, ytsareva, shoom3301, waterplea, meskill, marsibarsi, zig-green, defenderbass, super_oleg |
| Keywords | shared, library, webpack, plugin |

## Links

- npm: https://www.npmjs.com/package/@tinkoff/shared-library-webpack-plugin
- Repository: https://github.com/TinkoffCreditSystems/shared-library-webpack-plugin
- Homepage: https://github.com/TinkoffCreditSystems/shared-library-webpack-plugin#readme
- Issues: https://github.com/TinkoffCreditSystems/shared-library-webpack-plugin/issues
- npm.io page: https://npm.io/package/@tinkoff/shared-library-webpack-plugin

## Dependencies (3)

- [uuid](https://npm.io/package/uuid.md) ^8.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [jscodeshift](https://npm.io/package/jscodeshift.md) ^0.9.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-07-14
- 1.0.0-beta.8 (beta) — 2020-10-02
- 1.0.2 — 2021-02-25
- 1.0.1 — 2021-02-24
- 1.0.0 — 2020-10-16
- 1.0.0-beta.7 — 2020-09-22
- 1.0.0-beta.6 — 2020-09-22
- 1.0.0-beta.5 — 2020-08-20
- 1.0.0-beta.4 — 2020-07-13
- 1.0.0-beta.3 — 2020-06-17
- 1.0.0-beta.2 — 2020-06-15
- 1.0.0-beta.1 — 2020-06-01

## README

# SharedLibraryWebpackPlugin

[![npm](https://img.shields.io/npm/v/@tinkoff/shared-library-webpack-plugin)](https://www.npmjs.com/package/@tinkoff/shared-library-webpack-plugin) [![npm](https://img.shields.io/npm/dm/@tinkoff/shared-library-webpack-plugin)](https://www.npmjs.com/package/@tinkoff/shared-library-webpack-plugin)

`SharedLibraryWebpackPlugin` is a webpack plugin for sharing libraries between applications.

### Motivation

When the host application loads many micro apps bundled with a webpack, many JavaScript is loaded on a client page. In a perfect world, each app can share its libraries with other apps and meet the requirements:

1. Each app stays self-hosted.
2. Fallbacks for non-loaded packages.
3. Codesharing in runtime.
4. Different library versions work individually.

SharedLibraryWebpackPlugin came to us from a perfect world!

### Documentations

1. [Installation and configuration](docs/installation_and_configuration.md)
2. [How is it works?](docs/how_does_it_work.md)
3. [Sharing and Tree shaking](https://github.com/TinkoffCreditSystems/shared-library-webpack-plugin/tree/15f229429eaf4e9adedbd15b405686a142d0087e/docs/tree_shaking.md)
4. [The Plugin API](docs/the_plugin.md)

### Demo

There is [a host application with two micro-apps](https://github.com/IKatsuba/shared-library-plugin-demo). All apps are built with Angular. The client page loads 282.8kB of JavaScript \(gzip\) when it opens all pages.

We add SharedLibraryWebpackPlugin in each app build for sharing all Angular packages and zone.js.

```typescript
const {
  SharedLibraryWebpackPlugin,
} = require('@tinkoff/shared-library-webpack-plugin');

module.exports = {
  plugins: [
    new SharedLibraryWebpackPlugin({
      libs: [
        { name: '@angular/core', usedExports: [] },
        { name: '@angular/common', usedExports: [] },
        { name: '@angular/common/http', usedExports: [] },
        { name: '@angular/platform-browser', usedExports: ['DomSanitizer'] },
        { name: '@angular/platform-browser/animations', usedExports: [] },
        { name: '@angular/animations', usedExports: [] },
        { name: '@angular/animations/browser', usedExports: [] },
        'zone.js/dist/zone',
      ],
    }),
  ],
};
```

After that, the client page loads 174.6kB of JavaScript! It is 38% less!

### [Contributing](contributing.md)

### [License](license.md)

---
_Source: https://npm.io/package/@tinkoff/shared-library-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
