rblopes / generator-phaser-plus

[🛑 DISCONTINUED] It has been a long journey but development of `generator-phaser-plus` is now over. I recommend you have a look and fork `yandeu/phaser-project-template` instead.
https://github.com/yandeu/phaser-project-template
MIT License
146 stars 14 forks source link

Game.js does not rebuild on save #14

Closed mokargas closed 8 years ago

mokargas commented 8 years ago

I'm on Mac OSX 10.10.5 in a dev environment.

I've built a test project straight from the generator and am serving via gulp or npm start.

If I go into Logo.js under Objects and change the angle to say, 0.5 or 1.0 and save, gulp reports that game.js was changed (and the browser refreshes). However, the result of the change isn't persisted to game.js until I kill the server and restart it. There are no lint warnings or errors in evidence.

Any ideas what this could be?

rblopes commented 8 years ago

Hi, @mokargas, thanks for reporting the issue.

To further investigate the issue, I need some more information, like the Node.js and npm versions you're using, and I need you to check on other things.

Say, do the changes are persisted under the following conditions:

Try adding a console.log to your modified code and check if there's any output in the browser console (in Chrome Dev Tools, Safari Web Inspector etc.). Also, try changing to a bigger angle value, say 5.0, to spin the Logo faster, making the changes easier to see. Testing the game in "Incognito mode" may be a good idea too.

I'm almost sure this is related to #10, reported earlier this year. It happened to me a few times, but I haven't noticed this issue since back them.

mokargas commented 8 years ago

My bad man. I usually remember that stuff.

Versions: Node v6.2.2 NPM 3.10.5 Yeoman 1.8.4

Editor is Brackets 1.7.0

I tried all your suggestions, including adding things like new states and setting the angle to a large value. In the terminal output, I do see any update such as the following (prints once even if I save twice):

[BS] 1 file changed (game.js)
[07:27:05] Finished 'dev:scripts' after 360 ms

However, changes aren't reflected on disk (under the build folder's game.js) or subsequently the browser (via Incognito). They are persisted only after killing the server and restarting it. I've also tried setting full access permissions but the changes don't persist.

It's almost like gulp.dest is failing to overwrite silently

mokargas commented 8 years ago

Just an update

I ended up blowing away the Node 6.2.2/ NPM 3.10.5 environment completely, along with Homebrew and Yeoman.

After some lengthy trial and error, I couldn't get Watchify to trigger events on the old environment after first run, even via it's CLI. Instead I re-installed Node 4.4.7 stable from the Node.js website, which comes with NPM 2.15 (ancient I know) along with Yeoman and the generator.

It now works, and instead exhibits the "double save behavior", which is manageable.

rblopes commented 8 years ago

I tried testing with Node 6 with npm 3. I'm on Linux though, so honestly I can't exactly reproduce your issue here, since I don't own a Mac. All seems to be working fine, but this message right before Gulp fires up caught my attention:

(node:12205) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

I doubt it's graceful-fs fault here, but if that's the case, there's not much I can do about. graceful-fs is a deep dependency of Gulp and won't be upgraded for Gulp 3.

That's only half the story though. The "double save behavior" you described may be manageable but not acceptable. I'm in the middle of a somewhat big update for the project, perhaps a good time to look at those things again...

rblopes commented 8 years ago

Ok, working on a solution here. Could you test something for me?

Edit gulpfile.js/tasks/dev.js and replace (just comment out) the dev:script task with the following code:

gulp.task('dev:scripts', (function () {
  const watcher = watch(config.bundle)
    .on('log', $.util.log)
    .on('update', rebuild);
  return rebuild;
  function rebuild() {
    return watcher
      .bundle()
      .on('error', notifyError)
      .pipe(source('game.js'))
      .pipe(buffer())
      .pipe(gulp.dest(dirs.build))
      .pipe(server.stream());
  }
}()));

Also, comment out the lines defining the dev:watch task and its name in the default task dependencies.

It's a partial solution, no ESLint yet, but if that solves the 'double save' thing, I'll likely include it in the template.

mokargas commented 8 years ago

Hi rblopes.

This definitely works for me on both my Windows 7 and Mac OSX Yosemite dev platforms.

rblopes commented 8 years ago

Just published a new version with the complete updated task code in the sample project.