# @phylum/webpack-node

> Run a node process from a webpack bundle

Latest version **1.0.0-beta.3** (published 2019-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @phylum/webpack-node
pnpm add @phylum/webpack-node
yarn add @phylum/webpack-node
bun add @phylum/webpack-node
```

## 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.0-beta.3 |
| Published | 2019-04-06 |
| First published | 2019-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Max J. Polster |
| Maintainers | mpt |

## Links

- npm: https://www.npmjs.com/package/@phylum/webpack-node
- Repository: https://github.com/phylumjs/webpack-node
- Homepage: https://github.com/phylumjs/webpack-node#readme
- Issues: https://github.com/phylumjs/webpack-node/issues
- npm.io page: https://npm.io/package/@phylum/webpack-node

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^11.13.0

## Recent versions

- 1.0.0-beta.3 (latest) — 2019-04-06
- 1.0.0-beta.2 — 2019-04-06
- 1.0.0-beta.1 — 2019-04-06
- 1.0.0-beta.0 — 2019-04-06

## README

# Webpack Node Task
[![Build Status](https://travis-ci.com/phylumjs/webpack-node.svg?branch=master)](https://travis-ci.com/phylumjs/webpack-node)
[![Coverage Status](https://coveralls.io/repos/github/phylumjs/webpack-node/badge.svg?branch=master)](https://coveralls.io/github/phylumjs/webpack-node?branch=master)
[![Latest](https://img.shields.io/npm/v/@phylum/webpack-node.svg?label=latest) ![License](https://img.shields.io/npm/l/@phylum/webpack-node.svg?label=license)](https://npmjs.org/package/@phylum/webpack-node)

This package exposes a task that runs a node process for webpack bundled code and supports hot module replacement.

## Installation
```bash
npm i webpack @phylum/webpack @phylum/webpack-node
```

# Usage
The webpack node task runs a node process from bundled sources.
*Note, that the webpack task will not be started automatically by the webpack node task.*

```ts
import { Task } from '@phylum/pipeline';
import { WebpackTask } from '@phylum/webpack';
import { WebpackNodeTask } from '@phylum/webpack-node';

const bundle = new WebpackTask(...);

const node = new WebpackNodeTask(Task.value({
	main: bundle
}));

new Task(async t => {
	// Run the webpack compiler:
	await t.use(bundle);
	// Start a node process:
	await t.use(node);
});
```
*Note that the node task assumes, that the main bundle has already been compiled.*

## Hot Module Replacement
```ts
new WebpackNodeTask(Task.value({
	// Enable hot module replacement:
	mainHmr: true,
	main: bundle
}));
```
```ts
// Import the hmr client somewhere in your main process code...
import '@phylum/webpack-node/dist/hmr';
```
```ts
// ...or add it to your entry point:
entry: ['@phylum/webpack-node/dist/hmr', './src/main.js'],

// Optional. Include the hmr runtime:
plugins: [
	new webpack.HotModuleReplacementPlugin()
]
```
If the hmr runtime is not included or an update is rejected, the main process will be rebooted.

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