@bumble/rollup-watch-next
Use rollup.watch in tests with ease.
Last updated 6 months ago by jacksteamdev .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @bumble/rollup-watch-next 
SYNC missed versions from official npm registry.

rollup-watch-next

Extend rollup.watch with a convenient async iterator API, and emit watch start and close events to process.

Installation

npm i rollup-watch-next -D

Usage

import watch from 'rollup-watch-next'
import config from './rollup.config'

Use rollup.watch as an Async Iterator

const watcher = watch(config)

const { value } = await watcher.next('END')

console.log('Bundle complete')

Emit events to process

process.on('rollup-watch:start', id => {
  console.log('rollup.watch has started')
})
process.on('rollup-watch:close', id => {
  console.log('rollup.watch has closed')
})

const watcher = watch(config)
// 'rollup.watch has started'

console.log('watcher id', watcher.id)

watcher.close()
// 'rollup.watch has closed'

API

rollup-watch-next simply extends Rollup's native watch export with a next method.

watcher.next([eventCode])

Type: string

Use like an async iterator. Takes one of the following event codes:

await watcher.next('START')
await watcher.next('BUNDLE_START')
await watcher.next('BUNDLE_END')
await watcher.next('END')
await watcher.next('ERROR')
await watcher.next('FATAL')

Returns: Promise<{value, done}>

Resolves with the next event value that matches eventCode. Rejects if 'FATAL' occurs, unless eventCode === 'FATAL'. Does not reject with 'ERROR'.

Current Tags

  • 0.3.3                                ...           latest (6 months ago)

5 Versions

  • 0.3.3                                ...           6 months ago
  • 0.3.1                                ...           7 months ago
  • 0.3.0                                ...           7 months ago
  • 0.2.1                                ...           7 months ago
  • 0.2.0                                ...           7 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (6)

Copyright 2014 - 2016 © taobao.org |