@phylum/webpack-node
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.3 • Public • Published

Webpack Node Task

Build Status Coverage Status Latest License

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

Installation

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.

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

new WebpackNodeTask(Task.value({
	// Enable hot module replacement:
	mainHmr: true,
	main: bundle
}));
// Import the hmr client somewhere in your main process code...
import '@phylum/webpack-node/dist/hmr';
// ...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.

Readme

Keywords

none

Package Sidebar

Install

npm i @phylum/webpack-node

Weekly Downloads

1

Version

1.0.0-beta.3

License

MIT

Unpacked Size

17.5 kB

Total Files

14

Last publish

Collaborators

  • mpt