# co-react-webpack-build

> Webpack configuration for React apps

Latest version **1.0.25** (published 2022-05-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install co-react-webpack-build
pnpm add co-react-webpack-build
yarn add co-react-webpack-build
bun add co-react-webpack-build
```

Provides the commands `co-dev-server`, `co-prod-build`, `co-prod-server`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.25 |
| Published | 2022-05-20 |
| First published | 2021-05-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 17 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | Pablo Olivera |
| Maintainers | p.oliverav |

## Links

- npm: https://www.npmjs.com/package/co-react-webpack-build
- Homepage: https://github.com/polivera/co-react-webpack-build#readme
- npm.io page: https://npm.io/package/co-react-webpack-build

## Dependencies (17)

- [shelljs](https://npm.io/package/shelljs.md) ^0.8.5
- [webpack](https://npm.io/package/webpack.md) ^5.67.0
- [prettier](https://npm.io/package/prettier.md) ^2.5.1
- [css-loader](https://npm.io/package/css-loader.md) ^6.5.1
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.16.10
- [file-loader](https://npm.io/package/file-loader.md) ^6.2.0
- [webpack-cli](https://npm.io/package/webpack-cli.md) ^4.9.2
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.2.3
- [style-loader](https://npm.io/package/style-loader.md) ^3.3.1
- [@svgr/webpack](https://npm.io/package/@svgr/webpack.md) ^6.2.1
- [webpack-merge](https://npm.io/package/webpack-merge.md) ^5.8.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.16.11
- [webpack-dev-server](https://npm.io/package/webpack-dev-server.md) ^4.7.3
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.16.7
- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^5.5.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.16.7
- [@babel/plugin-transform-runtime](https://npm.io/package/@babel/plugin-transform-runtime.md) ^7.16.10

## Recent versions

- 1.0.25 (latest) — 2022-05-20
- 1.0.24 — 2022-05-19
- 1.0.23 — 2022-05-19
- 1.0.22 — 2022-01-22
- 1.0.19 — 2022-01-22
- 1.0.14 — 2022-01-21
- 1.0.13 — 2021-06-01
- 1.0.12 — 2021-06-01
- 1.0.11 — 2021-06-01
- 1.0.10 — 2021-06-01
- 1.0.9 — 2021-05-31
- 1.0.8 — 2021-05-30

## README

# React Module Federation Library

This package pre-configures webpack to work with module federation with react.

## Configuration

Changes on the configuration can be done through the package.json file, as well as indicate
which components should be exposes or consume.

|   Property   | Default Value |     type     | Description                                                                                                                                                                               |
|:------------:|:-------------:|:------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|     name     |      n/a      |    string    | This value will be used as package name in the federation url. <br/> Example: for the name 'package-name' the url will be: `packageName@http://localhost:1234/remoteEntry.js`             |
| sourceFolder |     ./src     |    string    |                                                                                                                                                                                           |
|     main     |   index.ts    |    string    | Entry file name. Webpack will look for it in the sourceFolder                                                                                                                             |
|     host     |   localhost   |    string    | Host to use. This will set webpack devServer.host                                                                                                                                         |
|     port     |     9000      |     int      | Port to use. This will set webpack devServer.port                                                                                                                                         |
|   exposes    |      [ ]      |    object    | A list of components to expose for module federation. The format should be: <br/> `{ "./ComponentName": "/path/to/component" }`                                                           |
|   remotes    |      [ ]      |    object    | A list of federated modules to consume. The format should be: <br/> `{ "ComponentName": "exposeName@http://host/remoteEntry.js" }`                                                        |
|    shared    |      [ ]      |    object    | A list of shared components. The format should be: <br/> `{ "react": { "singleton": true, "eager": true } }`<br/> The requiredVersion field will be retrieved from the dependency version |
| allowedHosts |     auto      | array/string | Allows you to whitelist services that are allowed to access the dev server. See [webpack documentation](https://webpack.js.org/configuration/dev-server/#devserverallowedhosts)           |

## Example of a package.json

```json
{
  "name": "test-app",
  "version": "1.0.0",
  "description": "Test App",
  "main": "index.ts",
  "port": 9091,
  "scripts": {
    "start": "co-dev-server",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Author",
  "license": "ISC",
  "homepage": "https://github.com/some-user/test-app#readme",
  "devDependencies": {
    "@types/jest": "^27.4.0",
    "@types/react": "^17.0.38",
    "@types/react-dom": "^17.0.11",
    "typescript": "^4.5.5"
  },
  "dependencies": {
    "co-react-webpack-build": "^1.0.22",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "remotes": {
    "RemoteComponent": "remoteComponent@http://localhost:9091/remoteEntry.js"
  },
  "exposes": {
    "./TestComponent": "./components/TestComponent/index.tsx"
  },
  "shared": {
    "react": {
      "singleton": true,
      "eager": true
    },
    "react-dom": {
      "singleton": true,
      "eager": true
    }
  }
}
```

---
_Source: https://npm.io/package/co-react-webpack-build · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
