Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: browserify/watchify
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f768b433774652d6b5257cd342e4353f81760637
Choose a base ref
...
head repository: browserify/watchify
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7b27a3c0d6bb796cef71faebfeb610ec62ad97b3
Choose a head ref

Commits on May 17, 2016

  1. link build badge to master branch

    and change it to svg
    a0viedo committed May 17, 2016
    Copy the full SHA
    074d6da View commit details

Commits on Jul 27, 2016

  1. Fixed typo in readme

    mjomble authored Jul 27, 2016
    Copy the full SHA
    230c72c View commit details

Commits on Oct 18, 2016

  1. Should be "b.bundle" not "w.bundle"

    I was rather confused by the "w.bundle", and I think it's a typo for b.bundle?
    palfrey authored Oct 18, 2016
    Copy the full SHA
    d49c5e9 View commit details

Commits on Oct 20, 2017

  1. Merge pull request #335 from palfrey/patch-1

    Should be "b.bundle" not "w.bundle"
    goto-bus-stop authored Oct 20, 2017
    Copy the full SHA
    e2a6e82 View commit details

Commits on Nov 1, 2017

  1. Merge pull request #326 from mjomble/patch-1

    Fixed typo in readme
    stevemao authored Nov 1, 2017
    Copy the full SHA
    114982d View commit details
  2. Merge pull request #319 from a0viedo/patch-1

    link build badge to master branch
    stevemao authored Nov 1, 2017
    Copy the full SHA
    cf05baa View commit details

Commits on Nov 17, 2017

  1. Copy the full SHA
    8147bc5 View commit details

Commits on Jan 27, 2018

  1. browserify@15

    feross committed Jan 27, 2018
    Copy the full SHA
    6de686b View commit details
  2. 3.10.0

    feross committed Jan 27, 2018
    Copy the full SHA
    5f7f27b View commit details

Commits on Feb 13, 2018

  1. test: add callbacks

    Using async fs functions without callbacks is deprecated and will
    throw in future versions. This adds a callback and checks that it
    does not error.
    BridgeAR committed Feb 13, 2018
    Copy the full SHA
    b2a2ab1 View commit details

Commits on Feb 15, 2018

  1. Merge pull request #353 from BridgeAR/master

    test: add callbacks
    feross authored Feb 15, 2018
    Copy the full SHA
    2bc76db View commit details

Commits on Mar 4, 2018

  1. Update to browserify@16

    Fixes #354
    feross committed Mar 4, 2018
    Copy the full SHA
    495b6f2 View commit details
  2. Merge pull request #355 from browserify/browserify-16

    Update to browserify@16
    feross authored Mar 4, 2018
    Copy the full SHA
    82669ad View commit details
  3. 3.11.0

    feross committed Mar 4, 2018
    Copy the full SHA
    11989b2 View commit details

Commits on Apr 4, 2018

  1. Support for working with transforms

    Informing Watchify about files to watch.
    Kamil93 authored Apr 4, 2018
    Copy the full SHA
    9ea8a65 View commit details
  2. Update readme.markdown

    Kamil93 authored Apr 4, 2018
    Copy the full SHA
    d924e9b View commit details

Commits on Apr 5, 2018

  1. Merge pull request #357 from Kamil93/patch-1

    Add transform 'file' event to readme
    goto-bus-stop authored Apr 5, 2018
    Copy the full SHA
    d232754 View commit details

Commits on May 16, 2018

  1. Merge pull request #351 from menzow/feature/update-docs

    Add troubleshooting information for silenced errors
    goto-bus-stop authored May 16, 2018
    Copy the full SHA
    1917270 View commit details

Commits on Feb 18, 2019

  1. upgrade dependencies: fix errors from npm audit

    Christian Strandenæs committed Feb 18, 2019
    Copy the full SHA
    d163b4f View commit details

Commits on Feb 19, 2019

  1. Merge pull request #362 from digipost/upgrade-deps

    upgrade dependencies: security vulnerability in braces < 2.3.1, brfs < 2.0.1
    goto-bus-stop authored Feb 19, 2019
    Copy the full SHA
    e90101b View commit details
  2. 3.11.1

    goto-bus-stop committed Feb 19, 2019
    Copy the full SHA
    c3fe218 View commit details

Commits on Jul 7, 2019

  1. Copy the full SHA
    bb2b429 View commit details
  2. Merge pull request #367 from Trott/update-readme-badge

    chore: Fix Travis-CI badge in readme.markdown
    goto-bus-stop authored Jul 7, 2019
    Copy the full SHA
    563a90d View commit details
  3. Copy the full SHA
    bd2f677 View commit details

Commits on Sep 27, 2019

  1. Change URLs from "Substack" (someones personal site & acc) to "browse…

    …rify" (#369)
    
    * Change URLs to browserify
    
    * fixup
    
    * Change URLs to browserify
    
    * Update package.json
    
    Co-Authored-By: Renée Kooi <renee@kooi.me>
    
    * Update readme.markdown
    
    Co-Authored-By: Renée Kooi <renee@kooi.me>
    soryy708 and goto-bus-stop committed Sep 27, 2019
    Copy the full SHA
    f79e59f View commit details

Commits on Jan 28, 2021

  1. Copy the full SHA
    3445775 View commit details
  2. update chokidar and anymatch (#378)

    Co-authored-by: Renée Kooi <renee@kooi.me>
    sseide and goto-bus-stop authored Jan 28, 2021
    Copy the full SHA
    bae5e02 View commit details
  3. Copy the full SHA
    b840f29 View commit details
  4. bump deps (#380)

    goto-bus-stop authored Jan 28, 2021
    Copy the full SHA
    5d4842a View commit details
  5. 4.0.0

    goto-bus-stop committed Jan 28, 2021
    Copy the full SHA
    7b27a3c View commit details
Showing with 97 additions and 32 deletions.
  1. +22 −0 .github/workflows/ci.yml
  2. +1 −0 .npmrc
  3. +0 −6 .travis.yml
  4. +8 −0 CHANGELOG.md
  5. +14 −11 package.json
  6. +44 −7 readme.markdown
  7. +2 −2 test/bin.js
  8. +2 −2 test/bin_brfs.js
  9. +2 −2 test/bin_pipe.js
  10. +2 −2 test/bin_standalone.js
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI

on: [push, pull_request]

jobs:
test:
name: Tests
strategy:
matrix:
node: [8.x, 10.x, 12.x, 14.x, 15.x]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Node.js ${{matrix.node}}
uses: actions/setup-node@v2-beta
with:
node-version: ${{matrix.node}}
- name: Install dependencies
run: npm install
- name: npm test
run: npm test
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# watchify Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 4.0.0
* Update dependencies.

This release drops support for Node.js versions older than 8.10, following the upgrade to `chokidar` 3.x.
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "watchify",
"version": "3.9.0",
"version": "4.0.0",
"description": "watch mode for browserify builds",
"main": "index.js",
"bin": "bin/cmd.js",
"engines": {
"node": ">= 8.10.0"
},
"dependencies": {
"anymatch": "^1.3.0",
"browserify": "^14.0.0",
"chokidar": "^1.0.0",
"anymatch": "^3.1.0",
"browserify": "^17.0.0",
"chokidar": "^3.4.0",
"defined": "^1.0.0",
"outpipe": "^1.1.0",
"through2": "^2.0.0",
"xtend": "^4.0.0"
"through2": "^4.0.2",
"xtend": "^4.0.2"
},
"devDependencies": {
"brfs": "^1.0.1",
"mkdirp": "~0.5.1",
"brfs": "^2.0.1",
"mkdirp": "^0.5.5",
"split": "^1.0.0",
"tape": "^4.2.2",
"tape": "^5.1.1",
"uglify-js": "^2.5.0",
"win-spawn": "^2.0.0"
},
@@ -26,9 +29,9 @@
},
"repository": {
"type": "git",
"url": "git://github.com/substack/watchify.git"
"url": "git://github.com/browserify/watchify.git"
},
"homepage": "https://github.com/substack/watchify",
"homepage": "https://github.com/browserify/watchify",
"keywords": [
"browserify",
"browserify-tool",
51 changes: 44 additions & 7 deletions readme.markdown
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

watch mode for [browserify](https://github.com/substack/node-browserify) builds

[![build status](https://secure.travis-ci.org/substack/watchify.png)](http://travis-ci.org/substack/watchify)
[![build status](https://secure.travis-ci.org/browserify/watchify.svg?branch=master)](http://travis-ci.org/browserify/watchify)

Update any source file and your browserify bundle will be recompiled on the
spot.
@@ -90,7 +90,7 @@ var watchify = require('watchify');

## watchify(b, opts)

watchify is a browserify [plugin](https://github.com/substack/node-browserify#bpluginplugin-opts), so it can be applied like any other plugin.
watchify is a browserify [plugin](https://github.com/browserify/browserify#bpluginplugin-opts), so it can be applied like any other plugin.
However, when creating the browserify instance `b`, **you MUST set the `cache`
and `packageCache` properties**:

@@ -107,7 +107,7 @@ var b = browserify({
});
```

**By default, watchify doesn't display any output, see [events](https://github.com/substack/watchify#events) for more info.**
**By default, watchify doesn't display any output, see [events](https://github.com/browserify/watchify#events) for more info.**

`b` continues to behave like a browserify instance except that it caches file
contents and emits an `'update'` event when a file changes. You should call
@@ -116,7 +116,7 @@ Calling `b.bundle()` extra times past the first time will be much faster due
to caching.

**Important:** Watchify will not emit `'update'` events until you've called
`w.bundle()` once and completely drained the stream it returns.
`b.bundle()` once and completely drained the stream it returns.

```js
var fs = require('fs');
@@ -134,7 +134,10 @@ b.on('update', bundle);
bundle();

function bundle() {
b.bundle().pipe(fs.createWriteStream('output.js'));
b.bundle()
.on('error', console.error)
.pipe(fs.createWriteStream('output.js'))
;
}
```

@@ -160,7 +163,7 @@ milliseconds will be the polling interval. For more info see Chokidar's
```js
var b = browserify({ cache: {}, packageCache: {} });
// watchify defaults:
b.plugin(bundle, {
b.plugin(watchify, {
delay: 100,
ignoreWatch: ['**/node_modules/**'],
poll: false
@@ -196,6 +199,27 @@ X bytes written (Y seconds)

with the number of bytes in the bundle X and the time in seconds Y.

# working with browserify transforms

If your custom transform for browserify adds new files to the bundle in a non-standard way without requiring.
You can inform Watchify about these files by emiting a 'file' event.

```
module.exports = function(file) {
return through(
function(buf, enc, next) {
/*
manipulating file content
*/
this.emit("file", absolutePathToFileThatHasToBeWatched);
next();
}
);
};
```

# install

With [npm](https://npmjs.org) do:
@@ -216,11 +240,24 @@ to get just the library.

## rebuilds on OS X never trigger

It may be related to a bug in `fsevents` (see [#250](https://github.com/substack/watchify/issues/205#issuecomment-98672850)
It may be related to a bug in `fsevents` (see [#250](https://github.com/browserify/watchify/issues/205#issuecomment-98672850)
and [stackoverflow](http://stackoverflow.com/questions/26708205/webpack-watch-isnt-compiling-changed-files/28610124#28610124)).
Try the `--poll` flag
and/or renaming the project's directory - that might help.

## watchify swallows errors

To ensure errors are reported you have to add a event listener to your bundle stream. For more information see ([browserify/browserify#1487 (comment)](https://github.com/browserify/browserify/issues/1487#issuecomment-173357516) and [stackoverflow](https://stackoverflow.com/a/22389498/1423220))

**Example:**
```
var b = browserify();
b.bundle()
.on('error', console.error)
...
;
```

# see also

- [budo](https://www.npmjs.com/package/budo) – a simple development server built on watchify
4 changes: 2 additions & 2 deletions test/bin.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ mkdirp.sync(tmpdir);
fs.writeFileSync(files.main, 'console.log(555)');

test('bin', function (t) {
t.plan(4);
t.plan(5);
var ps = spawn(cmd, [ files.main, '-o', files.bundle, '-v' ]);
var lineNum = 0;
ps.stderr.pipe(split()).on('data', function (line) {
@@ -27,7 +27,7 @@ test('bin', function (t) {
run(files.bundle, function (err, output) {
t.ifError(err);
t.equal(output, '555\n');
fs.writeFile(files.main, 'console.log(333)');
fs.writeFile(files.main, 'console.log(333)', t.ifError);
})
}
else if (lineNum === 2) {
4 changes: 2 additions & 2 deletions test/bin_brfs.js
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ fs.writeFileSync(files.main, [
fs.writeFileSync(files.lines, 'beep\nboop');

test('bin brfs', function (t) {
t.plan(4);
t.plan(5);
var ps = spawn(cmd, [
files.main,
'-t', require.resolve('brfs'), '-v',
@@ -37,7 +37,7 @@ test('bin brfs', function (t) {
run(files.bundle, function (err, output) {
t.ifError(err);
t.equal(output, 'BEEP\nBOOP\n');
fs.writeFile(files.lines, 'robo-bOOgie');
fs.writeFile(files.lines, 'robo-bOOgie', t.ifError);
})
}
else if (lineNum === 2) {
4 changes: 2 additions & 2 deletions test/bin_pipe.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ mkdirp.sync(tmpdir);
fs.writeFileSync(files.main, 'console.log(num * 2)');

test('bin with pipe', function (t) {
t.plan(4);
t.plan(5);
var ps = spawn(cmd, [
files.main,
'-o', 'uglifyjs - --enclose 11:num > ' + files.bundle,
@@ -31,7 +31,7 @@ test('bin with pipe', function (t) {
run(files.bundle, function (err, output) {
t.ifError(err);
t.equal(output, '22\n');
fs.writeFile(files.main, 'console.log(num * 3)');
fs.writeFile(files.main, 'console.log(num * 3)', t.ifError);
});
}
else if (lineNum === 2) {
4 changes: 2 additions & 2 deletions test/bin_standalone.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ mkdirp.sync(tmpdir);
fs.writeFileSync(files.main, 'console.log(555)');

test('bin with standalone', function (t) {
t.plan(4);
t.plan(5);
var ps = spawn(cmd, [ files.main, '-o', files.bundle, '-v', '-s', 'XXX' ]);
var lineNum = 0;
ps.stderr.pipe(split()).on('data', function (line) {
@@ -27,7 +27,7 @@ test('bin with standalone', function (t) {
run(files.bundle, function (err, output) {
t.ifError(err);
t.equal(output, '555\n');
fs.writeFile(files.main, 'console.log(333)');
fs.writeFile(files.main, 'console.log(333)', t.ifError);
})
}
else if (lineNum === 2) {