rollup-plugin-run

Run your bundle after you've built it

This package has been deprecated and is no longer maintained. Please use @rollup/plugin-run.
Last updated a year ago by rich_harris .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install rollup-plugin-run 
SYNC missed versions from official npm registry.

rollup-plugin-run

Run your bundles in Node once they're built.

Why

You're building a Node app with Rollup. During development, you want to restart the app each time your source code changes. One way to solve that would be to use nodemon targeted at Rollup's output, but that's a bit like using a bazooka to kill a fly.

Instead, you can add this simple plugin, which gives much faster results.

What

Each time your bundle is rebuilt, this plugin starts the generated file as a child process (after first closing the previous process, if it's not the first run).

It works with Rollup's code-splitting if you're using dynamic import(...) — the only constraint is that you have a single entry point specified in the config.

How

Install it in the usual manner...

npm i -D rollup-plugin-run

...then add it to your config:

// rollup.config.js
import run from 'rollup-plugin-run';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/index.js',
    format: 'cjs'
  },
  plugins: [
    run()
  ]
};

Note that we're using the cjs format, because we're running the app in Node.

The app is run in a child process using child_process.fork(...). You can pass through options such as env and execArgv. For example, to debug with sourcemaps using source-map-support you could do this:

// rollup.config.js
import run from 'rollup-plugin-run';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/index.js',
    format: 'cjs',
+    sourcemap: true
  },
  plugins: [
-    run()
+    run({
+      execArgv: ['-r', 'source-map-support/register']
+    })
  ]
};

When

By default, always. Since this feature is intended for development use, you may prefer to only include it when Rollup is being run in watch mode:

// rollup.config.js
import run from 'rollup-plugin-run';

+const dev = process.env.ROLLUP_WATCH === 'true';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/index.js',
    format: 'cjs'
  },
  plugins: [
-    run()
+    dev && run()
  ]
};

License

LIL

Current Tags

  • 1.1.0                                ...           latest (a year ago)

4 Versions

  • 1.1.0 [deprecated]           ...           a year ago
  • 1.0.2 [deprecated]           ...           a year ago
  • 1.0.1 [deprecated]           ...           a year ago
  • 1.0.0 [deprecated]           ...           a year ago
Downloads
Today 0
This Week 0
This Month 6
Last Day 0
Last Week 5
Last Month 7
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |