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.3.0 to 2.4.0

4

CHANGELOG.md
# rollup-watch changelog
## 2.4.0
* Only watch files that exist (disregard plugin helper modules) ([#3](https://github.com/rollup/rollup-watch/issues/3))
## 2.3.0

@@ -4,0 +8,0 @@

43

dist/rollup-watch.cjs.js

@@ -28,3 +28,3 @@ 'use strict';

var name = "rollup-watch";
var version = "2.3.0";
var version = "2.4.0";

@@ -47,17 +47,31 @@ function checkVersion ( name, localVersion ) {

var opts = { encoding: 'utf-8', persistent: true };
var FileWatcher = function FileWatcher ( file, data, callback, dispose ) {
var fsWatcher = fs.watch( file, { encoding: 'utf-8', persistent: true }, function (event) {
if ( event === 'rename' ) {
fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
var contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
try {
var fsWatcher = fs.watch( file, opts, function (event) {
if ( event === 'rename' ) {
fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
var contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
}
}
});
this.fileExists = true;
} catch ( err ) {
if ( err.code === 'ENOENT' ) {
// can't watch files that don't exist (e.g. injected
// by plugins somehow)
this.fileExists = false;
} else {
throw err;
}
});
}
};

@@ -113,2 +127,5 @@

// skip plugin helper modules
if ( /\0/.test( id ) ) return;
if ( !filewatchers.has( id ) ) {

@@ -119,3 +136,3 @@ var watcher = new FileWatcher( id, module.originalCode, triggerRebuild, function () {

filewatchers.set( id, watcher );
if ( watcher.fileExists ) filewatchers.set( id, watcher );
}

@@ -122,0 +139,0 @@ });

@@ -24,3 +24,3 @@ import EventEmitter from 'events';

var name = "rollup-watch";
var version = "2.3.0";
var version = "2.4.0";

@@ -43,17 +43,31 @@ function checkVersion ( name, localVersion ) {

var opts = { encoding: 'utf-8', persistent: true };
var FileWatcher = function FileWatcher ( file, data, callback, dispose ) {
var fsWatcher = fs.watch( file, { encoding: 'utf-8', persistent: true }, function (event) {
if ( event === 'rename' ) {
fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
var contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
try {
var fsWatcher = fs.watch( file, opts, function (event) {
if ( event === 'rename' ) {
fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
var contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
}
}
});
this.fileExists = true;
} catch ( err ) {
if ( err.code === 'ENOENT' ) {
// can't watch files that don't exist (e.g. injected
// by plugins somehow)
this.fileExists = false;
} else {
throw err;
}
});
}
};

@@ -109,2 +123,5 @@

// skip plugin helper modules
if ( /\0/.test( id ) ) return;
if ( !filewatchers.has( id ) ) {

@@ -115,3 +132,3 @@ var watcher = new FileWatcher( id, module.originalCode, triggerRebuild, function () {

filewatchers.set( id, watcher );
if ( watcher.fileExists ) filewatchers.set( id, watcher );
}

@@ -118,0 +135,0 @@ });

{
"name": "rollup-watch",
"version": "2.3.0",
"version": "2.4.0",
"description": "Watch files for changes and perform incremental rebuilds with Rollup",

@@ -5,0 +5,0 @@ "main": "dist/rollup-watch.cjs.js",

@@ -7,18 +7,32 @@ import EventEmitter from 'events';

const opts = { encoding: 'utf-8', persistent: true };
class FileWatcher {
constructor ( file, data, callback, dispose ) {
const fsWatcher = fs.watch( file, { encoding: 'utf-8', persistent: true }, event => {
if ( event === 'rename' ) {
fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
const contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
try {
const fsWatcher = fs.watch( file, opts, event => {
if ( event === 'rename' ) {
fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
const contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
}
}
});
this.fileExists = true;
} catch ( err ) {
if ( err.code === 'ENOENT' ) {
// can't watch files that don't exist (e.g. injected
// by plugins somehow)
this.fileExists = false;
} else {
throw err;
}
});
}
}

@@ -75,2 +89,5 @@ }

// skip plugin helper modules
if ( /\0/.test( id ) ) return;
if ( !filewatchers.has( id ) ) {

@@ -81,3 +98,3 @@ const watcher = new FileWatcher( id, module.originalCode, triggerRebuild, () => {

filewatchers.set( id, watcher );
if ( watcher.fileExists ) filewatchers.set( id, watcher );
}

@@ -84,0 +101,0 @@ });

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