Browserify, watchify and moving files around

256 views Asked by At

My team and I keep experiencing the same problem when we try to use browserify with watchify while developing our application.

Essentially here is the issue. Lets say we have the following file structure:

js
  -- folder1
    -- app.coffee
    -- required_file.coffee

and app.coffee has the following code:

RequiredFile = require('./required_file')

# Do whatever you were gonna do.

This works great for us and I've been so happy with how quickly our builds run now that we use watchify.

However, lets say that we then change our project structure a little bit:

js
  -- folder1
    -- app.coffee
  -- folder2
    -- required_file.coffee

but the contents of app.coffee don't change so its still doing the following:

RequiredFile = require('./required_file')

# Do whatever you were gonna do.

Now, the problem is that it doesn't seem like either Watchify or Browserify have a problem with this, which I suspect might be because of some sort of caching that's going on.

However, as soon that code gets pushed to our repo and another team member pulls it down, Browserify immediately complains it can't find ./required_file anymore since the require statement is incorrect, it should be ../folder2/required_file.

Can anyone explain to me why this happens and how we can go about preventing it from happening going forward?

0

There are 0 answers