Code Monkey home page Code Monkey logo

Comments (11)

greypants avatar greypants commented on August 19, 2024

Thanks for the heads up. I had noticed that on the project I'm working on now. I'll keep an eye on it.

from blendid.

heyimalex avatar heyimalex commented on August 19, 2024

I saw this referenced from the watchify issue, thought I'd point out that it's watchify v 0.8.1 that still works.

from blendid.

mikekidder avatar mikekidder commented on August 19, 2024

updated my comment... my typo... thanks

from blendid.

antoniobrandao avatar antoniobrandao commented on August 19, 2024

Using Watchify ~1.0.1 I get this

TypeError: Cannot read property 'cache' of undefined
at watchify (/Users/antoniobrandao/project/node_modules/watchify/index.js:13:27)

function watchify (b, opts) {
if (!opts) opts = {};
var cache = b._options.cache; <---- here it fails

from blendid.

heyimalex avatar heyimalex commented on August 19, 2024

@antoniobrandao Check the watchify docs, it works differently now; you wrap a browserify instance, and that instance needs to be created with certain options.

from blendid.

greypants avatar greypants commented on August 19, 2024

This issue has been fixed in the latest version of Watchify, but requires Browserify 5.x, which at the moment is incompatible with browserify-shim. As soon as that's worked out, I'll update those dependencies all the way. I did update watchify to ~0.10.1, but I'm not sure if it's been fixed there or not.

from blendid.

antoniobrandao avatar antoniobrandao commented on August 19, 2024

@heyimalex How would that apply to @greypants "gulp-starter"? In his example, there is a check to see whether we are "watching" and only in that case use Watchify, otherwise use browserify - I think. (am I wrong?)

Does your implementation work like that? Perhaps you could give me a tiny example code? :)

Thanks

from blendid.

greypants avatar greypants commented on August 19, 2024

The new implementation works a little differently. You initialize browserify first, then wrap it with watchify. The updated task would look something like this (I think):

gulp.task('browserify', function() {

  var bundler = browserify({
    // Required watchify args
    cache: {}, packageCache: {}, fullPaths: true,
    // Browserify Options
    entries: ['./src/javascript/app.coffee'],
    extensions: ['.coffee', '.hbs'],
    debug: true
  });

  var bundle = function() {
    return bundler
      .bundle()
      .on('error', handleErrors)
      .pipe(source('app.js'))
      .pipe(gulp.dest('./build/'));
  };

  if(global.isWatching) {
    bundler = watchify(bundler);
    bundler.on('update', bundle);
  }

  return bundle();
});

The docs are kind of confusing, but I think that's right.

BUT until browserify-shim supports browserify 5.x, we're stuck on old watchify, which uses the method currently in this repo.

from blendid.

heyimalex avatar heyimalex commented on August 19, 2024

I think you are "watching" if you get that error. The fix needs to go in the gulp-starter browserify task; instead of switching between browserify and watchify based on the global watching flag, always use browserify, and then, if the watching flag is set, wrap browserify with watchify. Also, the options watchify requires need to be added to the browserify constructor.

Not familiar with gulp-starter, but had the same issue when I upgraded watchify a couple of weeks ago and my browserify task looked similar.

from blendid.

antoniobrandao avatar antoniobrandao commented on August 19, 2024

@greypants in that code line 14, "bundle" returns undefined because it is only declared afterwards.

Moved it around, seems to work fine. Using Watchify ~1.0.1.

Will stick to it because I'm not needing browserify-shim at the moment :) Thanks !

from blendid.

greypants avatar greypants commented on August 19, 2024

Oh, good call. I'll update the comment. No problem!

from blendid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.