0.6.0 • Published 7 years ago

webpack-sandboxed v0.6.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

webpack-sandboxed   npm version Build Status Coverage Status Code Climate

Webpack in a sandbox. Run webpack on a in-memory file system, reading from a source string and outputting results as strings again. This is useful when using webpack for compiling bundles on the fly, e.g. on a web server.


Usage

import webpackSandboxed from 'webpack-sandboxed';

const options = {
  config: { /* webpack configuration */ },
  packages: [ /* names of modules to load in the sandbox */ ],
  includes: [ /* local file paths to load in the sandbox */ ],
  baseDir: 'base directory to resolve modules'
};

const sandbox = await webpackSandboxed(options);
const [bundle, stats] = sandbox.run("exports = {foo: 'bar'};");

API

webpackSandboxed(options: Options): WebpackRunner

Create a new instance of WebpackRunner.

Options

Options to configure webpack and webpack sandboxed.

  • config?: webpack.Configurationwebpack configuration
  • packages?: string[] – A list of node_modules to load into the virtual file system.
  • includes?: string[] – A list of directories to add to the virtual file system.
  • basedir?: string – The base directory to resolve modules from. Defaults to the parent directory of the webpack-sandboxed installation.

WebpackRunner

Webpack sandboxed instance.

  • run(source: string | Buffer): Promise<[WebpackBundle, webpack.Stats]> – Run webpack asynchronously (delegating to WebpackCompiler.run).

WebpackBundle

Result of a webpack sandboxed run.

  • [key: string]: Buffer – The set of files generated by webpack (bundles and assets).

Example

Please view the example directory for a complete example of how to use webpack sandboxed.

References

This project was inspired by others:

0.6.0

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

8 years ago