Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rollup-watch

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-watch - npm Package Compare versions

Comparing version 2.5.0 to 3.0.0

dist/rollup-watch.es.js

7

CHANGELOG.md
# rollup-watch changelog
## 3.0.0
* Don't check for version updates ([#12](https://github.com/rollup/rollup-watch/issues/12), [#26](https://github.com/rollup/rollup-watch/issues/26), [#34](https://github.com/rollup/rollup-watch/issues/34))
* Fix `initial` flag ([#13](https://github.com/rollup/rollup-watch/pull/13))
* Retain options object ([#24](https://github.com/rollup/rollup-watch/issues/24))
* Don't watch generated bundle ([#15](https://github.com/rollup/rollup-watch/issues/15))
## 2.5.0

@@ -4,0 +11,0 @@

181

dist/rollup-watch.cjs.js

@@ -6,5 +6,4 @@ 'use strict';

var EventEmitter = _interopDefault(require('events'));
var path = require('path');
var fs = require('fs');
var child_process = require('child_process');
var semver = require('semver');

@@ -28,34 +27,2 @@ function sequence ( array, fn ) {

function assign ( target ) {
var sources = [], len = arguments.length - 1;
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
sources.forEach( function (source) {
for ( var key in source ) {
if ( source.hasOwnProperty( key ) ) target[ key ] = source[ key ];
}
});
return target;
}
var name = "rollup-watch";
var version = "2.5.0";
function checkVersion ( name, localVersion ) {
return new Promise( function ( fulfil, reject ) {
child_process.exec( ("npm show " + name + " version"), function ( err, result ) {
if ( err ) return reject( err );
fulfil( result.trim() );
});
}).then( function (latestVersion) {
if ( semver.gt( latestVersion, localVersion ) ) {
var err = new Error( (name + " is out of date") );
err.code = 'OUT_OF_DATE';
err.localVersion = localVersion;
err.latestVersion = latestVersion;
}
});
}
var opts = { encoding: 'utf-8', persistent: true };

@@ -92,100 +59,98 @@

function watch ( rollup, options ) {
function watch$1 ( rollup, options ) {
var emitter = new EventEmitter();
process.nextTick( function () { return emitter.emit( 'event', { code: 'STARTING' }); } );
var dests = options.dest ? [ path.resolve( options.dest ) ] : options.target.map( function (target) { return path.resolve( target.dest ); } );
var filewatchers = new Map();
checkVersion( name, version )
.catch( function (err) {
if ( err.code === 'OUT_OF_DATE' ) {
// TODO offer to update
console.error( ("rollup-watch is out of date (you have " + (err.localVersion) + ", latest version is " + (err.latestVersion) + "). Update it with npm install -g rollup-watch") ); // eslint-disable-line no-console
}
})
.then( function () {
var filewatchers = new Map();
var rebuildScheduled = false;
var building = false;
var watching = false;
var rebuildScheduled = false;
var building = false;
var watching = false;
var timeout;
var cache;
var timeout;
var cache;
function triggerRebuild () {
clearTimeout( timeout );
rebuildScheduled = true;
function triggerRebuild () {
clearTimeout( timeout );
rebuildScheduled = true;
timeout = setTimeout( function () {
if ( !building ) {
rebuildScheduled = false;
build();
}
}, 50 );
timeout = setTimeout( function () {
if ( !building ) {
rebuildScheduled = false;
build();
}
}, 50 );
}
function build () {
if ( building ) return;
function build () {
if ( building ) { return; }
var start = Date.now();
var initial = !watching;
var opts = assign( {}, options, cache ? { cache: cache } : {});
var start = Date.now();
var initial = !watching;
if ( cache ) { options.cache = cache; }
emitter.emit( 'event', { code: 'BUILD_START' });
emitter.emit( 'event', { code: 'BUILD_START' });
building = true;
building = true;
return rollup.rollup( opts )
.then( function (bundle) {
// Save off bundle for re-use later
cache = bundle;
return rollup.rollup( options )
.then( function (bundle) {
// Save off bundle for re-use later
cache = bundle;
bundle.modules.forEach( function (module) {
var id = module.id;
bundle.modules.forEach( function (module) {
var id = module.id;
// skip plugin helper modules
if ( /\0/.test( id ) ) return;
// skip plugin helper modules
if ( /\0/.test( id ) ) { return; }
if ( !filewatchers.has( id ) ) {
var watcher = new FileWatcher( id, module.originalCode, triggerRebuild, function () {
filewatchers.delete( id );
});
if ( ~dests.indexOf( id ) ) {
throw new Error( 'Cannot import the generated bundle' );
}
if ( watcher.fileExists ) filewatchers.set( id, watcher );
}
if ( !filewatchers.has( id ) ) {
var watcher = new FileWatcher( id, module.originalCode, triggerRebuild, function () {
filewatchers.delete( id );
});
if ( options.targets ) {
return sequence( options.targets, function (target) {
var mergedOptions = Object.assign( {}, options, target );
return bundle.write( mergedOptions );
});
}
if ( watcher.fileExists ) { filewatchers.set( id, watcher ); }
}
});
return bundle.write( options );
})
.then( function () {
emitter.emit( 'event', {
code: 'BUILD_END',
duration: Date.now() - start,
initial: initial
});
}, function (error) {
emitter.emit( 'event', {
code: 'ERROR',
error: error
});
})
.then( function () {
building = false;
if ( rebuildScheduled ) build();
// Now we're watching
watching = true;
if ( options.targets ) {
return sequence( options.targets, function (target) {
var mergedOptions = Object.assign( {}, options, target );
return bundle.write( mergedOptions );
});
}
}
build();
});
return bundle.write( options );
})
.then( function () {
emitter.emit( 'event', {
code: 'BUILD_END',
duration: Date.now() - start,
initial: initial
});
}, function (error) {
emitter.emit( 'event', {
code: 'ERROR',
error: error
});
})
.then( function () {
building = false;
if ( rebuildScheduled ) { build(); }
});
}
// build on next tick, so consumers can listen for BUILD_START
process.nextTick( build );
return emitter;
}
module.exports = watch;
module.exports = watch$1;
import EventEmitter from 'events';
import { readFileSync, watch } from 'fs';
import * as fs from 'fs';
import { exec } from 'child_process';
import { gt } from 'semver';

@@ -23,34 +22,2 @@ function sequence ( array, fn ) {

function assign ( target ) {
var sources = [], len = arguments.length - 1;
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
sources.forEach( function (source) {
for ( var key in source ) {
if ( source.hasOwnProperty( key ) ) target[ key ] = source[ key ];
}
});
return target;
}
var name = "rollup-watch";
var version = "2.5.0";
function checkVersion ( name, localVersion ) {
return new Promise( function ( fulfil, reject ) {
exec( ("npm show " + name + " version"), function ( err, result ) {
if ( err ) return reject( err );
fulfil( result.trim() );
});
}).then( function (latestVersion) {
if ( gt( latestVersion, localVersion ) ) {
var err = new Error( (name + " is out of date") );
err.code = 'OUT_OF_DATE';
err.localVersion = localVersion;
err.latestVersion = latestVersion;
}
});
}
var opts = { encoding: 'utf-8', persistent: true };

@@ -60,3 +27,3 @@

try {
var fsWatcher = fs.watch( file, opts, function (event) {
var fsWatcher = watch( file, opts, function (event) {
if ( event === 'rename' ) {

@@ -68,3 +35,3 @@ fsWatcher.close();

// this is necessary because we get duplicate events...
var contents = fs.readFileSync( file, 'utf-8' );
var contents = readFileSync( file, 'utf-8' );
if ( contents !== data ) {

@@ -89,100 +56,92 @@ data = contents;

function watch ( rollup, options ) {
function watch$1 ( rollup, options ) {
var emitter = new EventEmitter();
process.nextTick( function () { return emitter.emit( 'event', { code: 'STARTING' }); } );
var filewatchers = new Map();
checkVersion( name, version )
.catch( function (err) {
if ( err.code === 'OUT_OF_DATE' ) {
// TODO offer to update
console.error( ("rollup-watch is out of date (you have " + (err.localVersion) + ", latest version is " + (err.latestVersion) + "). Update it with npm install -g rollup-watch") ); // eslint-disable-line no-console
}
})
.then( function () {
var filewatchers = new Map();
var rebuildScheduled = false;
var building = false;
var watching = false;
var rebuildScheduled = false;
var building = false;
var watching = false;
var timeout;
var cache;
var timeout;
var cache;
function triggerRebuild () {
clearTimeout( timeout );
rebuildScheduled = true;
function triggerRebuild () {
clearTimeout( timeout );
rebuildScheduled = true;
timeout = setTimeout( function () {
if ( !building ) {
rebuildScheduled = false;
build();
}
}, 50 );
timeout = setTimeout( function () {
if ( !building ) {
rebuildScheduled = false;
build();
}
}, 50 );
}
function build () {
if ( building ) return;
function build () {
if ( building ) { return; }
var start = Date.now();
var initial = !watching;
var opts = assign( {}, options, cache ? { cache: cache } : {});
var start = Date.now();
var initial = !watching;
if ( cache ) { options.cache = cache; }
emitter.emit( 'event', { code: 'BUILD_START' });
emitter.emit( 'event', { code: 'BUILD_START' });
building = true;
building = true;
return rollup.rollup( opts )
.then( function (bundle) {
// Save off bundle for re-use later
cache = bundle;
return rollup.rollup( options )
.then( function (bundle) {
// Save off bundle for re-use later
cache = bundle;
bundle.modules.forEach( function (module) {
var id = module.id;
bundle.modules.forEach( function (module) {
var id = module.id;
// skip plugin helper modules
if ( /\0/.test( id ) ) return;
// skip plugin helper modules
if ( /\0/.test( id ) ) { return; }
if ( !filewatchers.has( id ) ) {
var watcher = new FileWatcher( id, module.originalCode, triggerRebuild, function () {
filewatchers.delete( id );
});
if ( watcher.fileExists ) filewatchers.set( id, watcher );
}
if ( !filewatchers.has( id ) ) {
var watcher = new FileWatcher( id, module.originalCode, triggerRebuild, function () {
filewatchers.delete( id );
});
if ( options.targets ) {
return sequence( options.targets, function (target) {
var mergedOptions = Object.assign( {}, options, target );
return bundle.write( mergedOptions );
});
}
if ( watcher.fileExists ) { filewatchers.set( id, watcher ); }
}
});
return bundle.write( options );
})
.then( function () {
emitter.emit( 'event', {
code: 'BUILD_END',
duration: Date.now() - start,
initial: initial
});
}, function (error) {
emitter.emit( 'event', {
code: 'ERROR',
error: error
});
})
.then( function () {
building = false;
if ( rebuildScheduled ) build();
// Now we're watching
watching = true;
if ( options.targets ) {
return sequence( options.targets, function (target) {
var mergedOptions = Object.assign( {}, options, target );
return bundle.write( mergedOptions );
});
}
}
build();
});
return bundle.write( options );
})
.then( function () {
emitter.emit( 'event', {
code: 'BUILD_END',
duration: Date.now() - start,
initial: initial
});
}, function (error) {
emitter.emit( 'event', {
code: 'ERROR',
error: error
});
})
.then( function () {
building = false;
if ( rebuildScheduled ) { build(); }
});
}
build();
return emitter;
}
export default watch;
export default watch$1;
{
"name": "rollup-watch",
"version": "2.5.0",
"version": "3.0.0",
"description": "Watch files for changes and perform incremental rebuilds with Rollup",
"main": "dist/rollup-watch.cjs.js",
"jsnext:main": "dist/rollup-watch.es6.js",
"jsnext:main": "dist/rollup-watch.es.js",
"files": [
"src", "dist", "README.md"
"src",
"dist",
"README.md"
],

@@ -17,6 +19,3 @@ "scripts": {

},
"repository": {
"type": "git",
"url": "git+https://github.com/rollup/rollup-watch.git"
},
"repository": "rollup/rollup-watch",
"keywords": [

@@ -34,11 +33,9 @@ "rollup",

"devDependencies": {
"eslint": "^2.11.1",
"mocha": "^2.5.3",
"rollup": "^0.28.0",
"rollup-plugin-buble": "^0.10.0",
"rollup-plugin-json": "^2.0.0"
},
"dependencies": {
"semver": "^5.1.0"
"eslint": "^3.12.2",
"mocha": "^3.2.0",
"rollup": "^0.39.0",
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-json": "^2.0.0",
"sander": "^0.6.0"
}
}
import EventEmitter from 'events';
import * as path from 'path';
import * as fs from 'fs';
import { sequence } from './utils/promise.js';
import { assign } from './utils/object.js';
import { name, version } from '../package.json';
import checkVersion from './utils/checkVersion.js';

@@ -44,95 +42,93 @@ const opts = { encoding: 'utf-8', persistent: true };

process.nextTick( () => emitter.emit( 'event', { code: 'STARTING' }) );
const dests = options.dest ? [ path.resolve( options.dest ) ] : options.target.map( target => path.resolve( target.dest ) );
let filewatchers = new Map();
checkVersion( name, version )
.catch( err => {
if ( err.code === 'OUT_OF_DATE' ) {
// TODO offer to update
console.error( `rollup-watch is out of date (you have ${err.localVersion}, latest version is ${err.latestVersion}). Update it with npm install -g rollup-watch` ); // eslint-disable-line no-console
}
})
.then( () => {
let filewatchers = new Map();
let rebuildScheduled = false;
let building = false;
let watching = false;
let rebuildScheduled = false;
let building = false;
let watching = false;
let timeout;
let cache;
let timeout;
let cache;
function triggerRebuild () {
clearTimeout( timeout );
rebuildScheduled = true;
function triggerRebuild () {
clearTimeout( timeout );
rebuildScheduled = true;
timeout = setTimeout( () => {
if ( !building ) {
rebuildScheduled = false;
build();
}
}, 50 );
timeout = setTimeout( () => {
if ( !building ) {
rebuildScheduled = false;
build();
}
}, 50 );
}
function build () {
if ( building ) return;
function build () {
if ( building ) return;
let start = Date.now();
let initial = !watching;
let opts = assign( {}, options, cache ? { cache } : {});
let start = Date.now();
let initial = !watching;
if ( cache ) options.cache = cache;
emitter.emit( 'event', { code: 'BUILD_START' });
emitter.emit( 'event', { code: 'BUILD_START' });
building = true;
building = true;
return rollup.rollup( opts )
.then( bundle => {
// Save off bundle for re-use later
cache = bundle;
return rollup.rollup( options )
.then( bundle => {
// Save off bundle for re-use later
cache = bundle;
bundle.modules.forEach( module => {
const id = module.id;
bundle.modules.forEach( module => {
const id = module.id;
// skip plugin helper modules
if ( /\0/.test( id ) ) return;
// skip plugin helper modules
if ( /\0/.test( id ) ) return;
if ( !filewatchers.has( id ) ) {
const watcher = new FileWatcher( id, module.originalCode, triggerRebuild, () => {
filewatchers.delete( id );
});
if ( ~dests.indexOf( id ) ) {
throw new Error( 'Cannot import the generated bundle' );
}
if ( watcher.fileExists ) filewatchers.set( id, watcher );
}
if ( !filewatchers.has( id ) ) {
const watcher = new FileWatcher( id, module.originalCode, triggerRebuild, () => {
filewatchers.delete( id );
});
if ( options.targets ) {
return sequence( options.targets, target => {
const mergedOptions = Object.assign( {}, options, target );
return bundle.write( mergedOptions );
});
}
if ( watcher.fileExists ) filewatchers.set( id, watcher );
}
});
return bundle.write( options );
})
.then( () => {
emitter.emit( 'event', {
code: 'BUILD_END',
duration: Date.now() - start,
initial
});
}, error => {
emitter.emit( 'event', {
code: 'ERROR',
error
});
})
.then( () => {
building = false;
if ( rebuildScheduled ) build();
// Now we're watching
watching = true;
if ( options.targets ) {
return sequence( options.targets, target => {
const mergedOptions = Object.assign( {}, options, target );
return bundle.write( mergedOptions );
});
}
}
build();
});
return bundle.write( options );
})
.then( () => {
emitter.emit( 'event', {
code: 'BUILD_END',
duration: Date.now() - start,
initial
});
}, error => {
emitter.emit( 'event', {
code: 'ERROR',
error
});
})
.then( () => {
building = false;
if ( rebuildScheduled ) build();
});
}
// build on next tick, so consumers can listen for BUILD_START
process.nextTick( build );
return emitter;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc