Skip to content

Commit

Permalink
Add fork of @rollup/plugin-run with build artifacts committed
Browse files Browse the repository at this point in the history
See <rollup/plugins#1699>, this is a built
version of that branch. NPM can consume this by referring to a github
URL in package.json.
  • Loading branch information
mkantor committed Apr 1, 2024
1 parent 42ee3f0 commit 3b0bc8d
Show file tree
Hide file tree
Showing 24 changed files with 860 additions and 0 deletions.
124 changes: 124 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,124 @@
# @rollup/plugin-run ChangeLog

## v3.1.0

_2024-04-01_

### Features

- feat: add `input` option (51192d5)

### Updates

- refactor: extract reusable consts from a test (fe7360d)
- chore: add test for multiple entry points (7efa265)

## v3.0.2

_2023-10-05_

### Bugfixes

- fix: ensure rollup 4 compatibility [#1595](https://github.com/rollup/plugins/pull/1595)

## v3.0.1

_2022-10-21_

### Updates

- chore: update rollup dependencies ([3038271](https://github.com/rollup/plugins/commit/303827191ede6b2e4eade96c6968ed16a587683f))

## v3.0.0

_2022-10-10_

### Breaking Changes

- fix: prepare for Rollup 3 [#1285](https://github.com/rollup/plugins/pull/1285)

## v2.1.0

_2021-07-29_

### Features

- feat: add `allowRestarts` option (#820)

### Updates

- chore: upgrade TypeScript (#714)
- chore: update dependencies (4428bff)

## v2.0.2

_2020-04-12_

### Bugfixes

- fix: use correct hook for reading options, handle facade chunks (#292)

### Updates

- refactor: use Typescript (#237)

## v2.0.1

_2020-03-30_

### Bugfixes

- fix: remove rollup v1 from peerDeps (0eb4d59)

## v2.0.0

_2020-03-29_

- chore: republish rollup v2 changes, includes breaking Rollup function signature change

## v1.2.2

_2020-03-29_

- chore: revert rollup v2 changes and republish. resolves breaking changes for rollup v1.x.

## v1.2.1

_2020-03-24_

### Bugfixes

- fix: plugin could fork before bundle generated (#281)
- fix: Support assets (#240)

### Updates

- chore: update devDeps (1b08a83)

## v1.2.0

_2020-01-04_

### Features

- feat: add typings (#115)

### Updates

- chore: update readme, linting (e7ff386)

## 1.1.0

- Allow arguments and options to be passed to `child_process.fork`

## 1.0.2

- Warn if Rollup version is too low

## 1.0.1

- Handle output files with different names from input files

## 1.0.0

- First release
185 changes: 185 additions & 0 deletions README.md
@@ -0,0 +1,185 @@
[npm]: https://img.shields.io/npm/v/@rollup/plugin-run
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-run
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-run
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-run

[![npm][npm]][npm-url]
[![size][size]][size-url]
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)

# @rollup/plugin-run

🍣 A Rollup plugin which runs your bundles in Node once they're built.

Using this plugin gives much faster results compared to what you would do with [nodemon](https://nodemon.io/).

## Requirements

This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v2.0.0+.

## Install

Using npm:

```console
npm install @rollup/plugin-run --save-dev
```

## Usage

Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:

```js
import run from '@rollup/plugin-run';

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

Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). If the build produces any errors, the plugin will write a 'alias' character to stderr, which should be audible on most systems.

The plugin `forks` a child process with the generated file, every time the bundle is rebuilt (after first closing the previous process, if it's not the first run).

_Note: This plugin 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._

## Options

This plugin supports pass through option available for [child_process.fork(...)](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options).

Example:

Debugging with sourcemaps using [source-map-support](https://www.npmjs.com/package/source-map-support):

```diff
// 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']
+ })
]
};
```

### `allowRestarts`

Type: `Boolean`<br>
Default: `false`

If `true`, instructs the plugin to listen to `stdin` for the sequences listed below followed by enter (carriage return).

#### `stdin` Input Actions

When this option is enabled, `stdin` will listen for the following input and perform the associated action:

- `restart` → Kills the currently running bundle and starts it again. _Note: This does not create a new bundle, the bundle is run again "as-is". This can be used to test configuration changes or other changes that are made without modifying your source_
Also allowed: `rs`, `CTRL+K`

- `clear` → Clears the screen of all text
Also allowed: `cls`, `CTRL+L`

### `input`

Type: `String`<br>
Default: `null`

Specifies the entry point this plugin will use. Not necessary if you only have a single entry point.

## Practical Example

The feature is usually intended for development use, you may prefer to only include it when Rollup is being run in watch mode:

```diff
// 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()
]
};
```

## Meta

[CONTRIBUTING](/.github/CONTRIBUTING.md)

[LICENSE (MIT)](/LICENSE)

---

PR:

feat(run): add `input` option

<!--
⚡️ katchow! We ❤️ Pull Requests!
If you remove or skip this template, you'll make the 🐼 sad and the mighty god
of Github will appear and pile-drive the close button from a great height
while making animal noises.
Pull Request Requirements:
* Please include tests to illustrate the problem this PR resolves.
* Please lint your changes by running `npm run lint` before creating a PR.
* Please update the documentation in `/docs` where necessary
Please place an x (no spaces - [x]) in all [ ] that apply.
-->

<!-- the plugin(s) this PR is for -->

## Rollup Plugin Name: `run`

This PR contains:

- [ ] bugfix
- [x] feature
- [ ] refactor
- [ ] documentation
- [ ] other

Are tests included?

- [x] yes (_bugfixes and features will not be merged without tests_)
- [ ] no

Breaking Changes?

- [ ] yes (_breaking changes will not be merged unless absolutely necessary_)
- [x] no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

### Description

<!--
Please be thorough and clearly explain the problem being solved.
* If this PR adds a feature, look for previous discussion on the feature by searching the issues first.
* Is this PR related to an issue?
-->

This changeset adds an `input` option to the `run` plugin. This options allows specifying which entry point to run if you have multiple in your bundle.
74 changes: 74 additions & 0 deletions dist/cjs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cjs/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3b0bc8d

Please sign in to comment.