Browse Source

implement rollup --watch

ghi-672
Rich-Harris 8 years ago
parent
commit
7485b60d45
  1. 1
      bin/help.md
  2. 3
      bin/rollup
  3. 16
      bin/runRollup.js
  4. 1
      package.json

1
bin/help.md

@ -9,6 +9,7 @@ Basic options:
-h, --help Show this help message
-c, --config Use this config file (if argument is used but value
is unspecified, defaults to rollup.config.js)
-w, --watch Watch files in bundle and rebuild on changes
-i, --input Input (alternative to <entry file>)
-o, --output <output> Output (if absent, prints to stdout)
-f, --format [es6] Type of output (amd, cjs, es6, iife, umd)

3
bin/rollup

@ -20,7 +20,8 @@ command = minimist( process.argv.slice( 2 ), {
n: 'name',
o: 'output',
u: 'id',
v: 'version'
v: 'version',
w: 'watch'
}
});

16
bin/runRollup.js

@ -1,6 +1,7 @@
require( 'source-map-support' ).install();
var path = require( 'path' );
var relative = require( 'require-relative' );
var handleError = require( './handleError' );
var rollup = require( '../' );
@ -127,7 +128,20 @@ function execute ( options, command ) {
});
try {
bundle( options ).catch( handleError );
if ( command.watch ) {
let watch;
try {
watch = relative( 'rollup-watch', process.cwd() );
} catch ( err ) {
// TODO offer to install rollup-watch
throw err;
}
watch( options );
} else {
bundle( options ).catch( handleError );
}
} catch ( err ) {
handleError( err );
}

1
package.json

@ -63,6 +63,7 @@
"dependencies": {
"chalk": "^1.1.1",
"minimist": "^1.2.0",
"require-relative": "^0.8.7",
"source-map-support": "^0.4.0"
},
"files": [

Loading…
Cancel
Save