Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When serving using a development server, the files are not properly refreshed #10

Open
julienw opened this issue Jan 22, 2016 · 4 comments

Comments

@julienw
Copy link

julienw commented Jan 22, 2016

I use [email protected] and [email protected].

Here is my quite simple gobblefile:

'use strict';
var gobble = require('gobble');

module.exports = gobble([
  gobble('src/root'),
  gobble('src/js').transform('babel', {}).transform('browserify', {
    entries: 'wobble.js',
    dest: 'bundle.js'
  })
]);

When I change a dependency (even a direct dependency from the main js file) the bundle.js file is not properly updated automatically, despite gobble outputting:

build invalidated (1 file changed). restarting
gobble: 01-babel done in 1ms
gobble: 02-browserify done in 33ms
gobble: 03-merge done in 2ms
gobble: build completed in 39ms
gobble:

I use ES6 modules transformed by babel, so maybe that could be a reason, but I don't believe so. Looking into the .gobblz directory I can see that Babel properly picks up my changes but not browserify.

@julienw
Copy link
Author

julienw commented Jan 22, 2016

I did a simple project adapted from my bigger project here: https://github.com/julienw/wobble/tree/gobble-issue, so you can clone the repository and checkout the gobble-issue branch.

Then you can run npm run serve to run the gobble server, and direct your browser to http://localhost:4567. Then you can modify src/js/grid.js to for example return something else and refresh your browser, you'll see nothing happens.

@julienw
Copy link
Author

julienw commented Jan 22, 2016

I think the issue is that in the cache object, the grid.js file id and file are /home/julien/perso/git/woggle/.gobble/01-babel/.cache/grid.js, and inputdir is something like /home/julien/perso/git/woggle/.gobble/01-babel/1 (with the last number that's incrementing with rebuilds).
So in the function cacheDependency where we replace inputdir by @, this doesn't work.

Now I don't know why the dep's file and id are in .cache... Should we also try to replace the cache dir ? Do we have this directory path somewhere ?

@julienw julienw changed the title When serving using a development server, the file are not properly refreshed When serving using a development server, the files are not properly refreshed Jan 22, 2016
@julienw
Copy link
Author

julienw commented Jan 23, 2016

To me, there are 4 ways to fix this:

  1. Remove the cache mechanism. This is handy but this is broken. And then rewrite it.
  2. Make it work with current this.changes values.
  3. Fix this.changes values in gobble core.
  4. Base the functionality on something else than this.changes, which seems to be an internal non-garanteed API.

I'd suggest to do 1 first and then decide whether to do 2 3 or 4...

@julienw
Copy link
Author

julienw commented Jan 27, 2016

I disabled the cache in https://github.com/julienw/gobble-browserify/tree/disable-cache and now it works fine for me. It's likely slower for big projects but I don't understand all this good enough to do better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant