fuse-box-node-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

fuse-box-node-plugin

semantic-release Build Status GitHub issues devDependencies Status dependencies Status

Plugin for fuse-box to allow inclusion of .node binaries and related dependencies

Usage

Install via npm i fuse-box-node-plugin --save-dev.

Configuration

NodePlugin follows the factorization and configuration pattern of official fuse-box plugins.

Including const {NodePlugin} = require("fuse-box-node-plugin"); will return a factory function, which accepts an options literal in the following format:

interface NodePluginOptions {
    // file path to the .node file
    file: string;
 
    // a root folder to be used when copying over, defaults to file's dirname
    root?: string;
 
    // output folder for NodePlugin assets. defaults to "modules"
    moduleFolder?: string
 
    // defaults to file's basename, defines subfolder in moduleFolder
    identifier?: string;
 
    // a list of globs relative root-folder, matching files will be copied into the bundle
    relativeDependencies?: string[];
}

Examples

Usage with sharp

The sharp-package creates platform specific files during npm's prebuild-step.

  • a native node module sharp.node in node_modules/sharp/Build/Release/
  • a few dozen library files in node_modules/sharp/vendor/

sharp.node requires most of these files, depending on features used in your code, and looks for them relative to itself.

To include sharp in your fuse-box bundle add NodePlugin to your plugin configuration:

plugins: [
  NodePlugin({
      file: "node_modules/sharp/build/Release/sharp.node",
      root: "node_modules/sharp",
      relativeDependencies: ["**.dll", "vendor/**"]
  })
]

This will generate a modules/sharp/ directory in your configured output, which mirrors the tree structure of node_modules/sharp for all files matching relativeDependencies.

Package Sidebar

Install

npm i fuse-box-node-plugin

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

11.1 kB

Total Files

9

Last publish

Collaborators

  • wmathes