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

watch --server --optimize fails to find almond.js #22

Closed
Coneko opened this issue Aug 12, 2012 · 13 comments
Closed

watch --server --optimize fails to find almond.js #22

Coneko opened this issue Aug 12, 2012 · 13 comments

Comments

@Coneko
Copy link

Coneko commented Aug 12, 2012

$ mimosa watch --server --optimize
18:32:33 - Adding compiler: template/handlebars-compiler
18:32:34 - Adding compiler: css/stylus-compiler
18:32:34 - Adding compiler: javascript/coffee-compiler
18:32:34 - Watching <project_path>/assets
18:32:35 - JavaScript Lint Error: 'AppRouter' is already defined., in file [<project_path>/public/javascripts/router.js], at line number [11]
18:32:35 - JavaScript Lint Error: Did you mean to return a conditional instead of an assignment?, in file [<project_path>/public/javascripts/views/map.js], at line number [7]
18:32:35 - JavaScript Lint Error: 'MapView' is already defined., in file [<project_path>/public/javascripts/views/map.js], at line number [11]
18:32:35 - Compiled/copied <project_path>/public/javascripts/main.js
18:32:35 - Compiled/copied <project_path>/public/javascripts/app.js
18:32:35 - Compiled/copied <project_path>/public/javascripts/router.js
18:32:35 - Compiled/copied <project_path>/public/javascripts/views/map.js
18:32:40 - Mimosa is starting your server: <project_path>/server.coffee
   info  - socket.io started
Express server listening on port 3000 in development mode
18:32:40 - Beginning requirejs optimization for module [[main]]
18:32:43 - The compiled file [[<project_path>/public/javascripts/main-built.js]] is ready for use.
18:32:43 - Requirejs optimization complete.

Now I modify map.coffee, triggering a recompilation:

18:33:03 - JavaScript Lint Error: Did you mean to return a conditional instead of an assignment?, in file [<project_path>/public/javascripts/views/map.js], at line number [7]
18:33:03 - JavaScript Lint Error: 'MapView' is already defined., in file [<project_path>/public/javascripts/views/map.js], at line number [11]
18:33:03 - Compiled/copied <project_path>/public/javascripts/views/map.js
18:33:04 - Beginning requirejs optimization for module [[main]]
18:33:05 - The compiled file [[<project_path>/public/javascripts/main-built.js]] is ready for use.
18:33:05 - Requirejs optimization complete.

events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: ENOENT, lstat '<project_path>/public/javascripts/almond.js'

Neither mimosa watch --server nor mimosa watch --optimize exhibit this problem, so it's in the interaction between the two flags.

@dbashford
Copy link
Owner

Do you have removeCombined ticked on?

@Coneko
Copy link
Author

Coneko commented Aug 12, 2012

No, I turned it off after you mentioned it caused problems with live recompilation.

But I never saw an almond.js in the public/javascripts directory before, so it probably gets deleted regardless of whether that flag is enabled or not.

@dbashford
Copy link
Owner

almond needs to be in the public directory for r.js to use it. So at the beginning of the r.js run I write it to public. And when it is all done, I remove it, since it isn't really part of the app. So the ENOENT you are seeing is from the attempted removal. Which is odd, because I'm not sure why it wouldn't be there. There is really only one possibility, it was there (hence your -built file working correctly) and it was removed (hence you never seeing it before) and for some reason it attempts to remove it again.

I was thinking removeCombined may have removed it first, and caused the issue, but I can't seem to make that happen that way locally.

I can push a simple fix to make sure the file is there before it attempts to removes it, but circumstances should dictate it only being removed once.

@dbashford
Copy link
Owner

Something about having a ton of files is making this happen. Thankfully I can now reproduce this.

@dbashford
Copy link
Owner

This was a fun one to track down. I have a fix for this, but it'll need to wait until tomorrow, it is getting late. Long story, but if you need to avoid this happening in the next 12 hours or so, turn off live reload via the config for a bit. Thankfully the author of watch-connect gave me push rights on git, and publish rights on npm, so I'll be able to get this done without having to wait for someone else to work on their schedule.

@dbashford
Copy link
Owner

Just pushed v0.0.19alpha to npm. Give it a go. Let me know all the things I broke fixing this. =)

Once I'm feature complete I'll go to beta and try and get a bunch of folks using the library. I'll publicize. And the primary goal from beta to 1.0 will be to fix bugs, add anything people identify as critical, and most certainly get a slew of tests in place so I'm not breaking things fixing other things quite so much.

@Coneko
Copy link
Author

Coneko commented Aug 13, 2012

No change, still crashes every time.

Making a tool that can handle such a big project presents quite a bit of challenges, so don't get discouraged.

I'll do my best to help you debug these issues. (And the next ones I'm about to post)

@dbashford
Copy link
Owner

It's awesome that someone with such a big project is using it, it is getting me to shake things out in ways I probably wouldn't have been able to otherwise.

I think we covered this before, but do you have your own server.coffee that you got via mimosa new or are you depending entirely on Mimosa's internals to serve up your files for you?

@Coneko
Copy link
Author

Coneko commented Aug 13, 2012

My project is a bit different from how the mimosa new is set up, but I haven't changed the server.coffee file much.
I got rid of the routes/index.coffee file and serve a static index.html page.
The rest is the same.

@dbashford
Copy link
Owner

Do a few things...

First, verify in your package.json that you are pointing at watch-connect 0.3.2. This is likely the case.

Back up your package.json (if you aren't version controlled) and run mimosa update. It's been awhile since I coded that command, and I was rushed off it to something else for work, so it didn't get tested like I'd have liked to, but it should update your package.json dependencies, including watch-connect from 0.3.2 to 0.3.3, and then run npm install. The idea is, you shouldn't need to know what versions of libraries you need to have (as in the case we have here), Mimosa should be able to keep you up to date with what you need and I should just be able to say, in the release notes 'please run mimosa update'. I'm only asking you to back it up in the event mimosa update mangles it.

Or, optionally, just update the package.json yourself and run npm install, but it would give me warm fuzzies to know mimosa update worked out for you. =)

Ensure in your server.coffee that almond.js is being excluded, and that the line of code looks something like this:

exclude:["almond\.js"]

It is a regex now, so it is best to escape the period.

@Coneko
Copy link
Author

Coneko commented Aug 13, 2012

Yep, that's exactly what was wrong. I haven't touched the package.json file, so I can't tell you whether it gets mangled or not, but it got updated.

Speaking of dependencies, I saw your issue requirejs/r.js#253, is optimize broken right now? Because I just tried making a new project with mimosa new to try and reproduce this issue, but all that comes out in main-built.js is (function(){require(["main"])})(). Maybe it's the mimosa new template?

Want me to open a new issue about that?

@Coneko Coneko closed this as completed Aug 13, 2012
@dbashford
Copy link
Owner

If you comment out the urlArgs portion of the config in the main.coffee, does it work?

If so, it isn't 253. 253 is what happens (in my Angular project) when you upgrade requirejs from 2.0.4 to 2.0.5. I found this problem when I copied the fix for requirejs/r.js#247 into my local install of Mimosa. That is the issue I brought up because of the urlArgs problem.

I'm hopeful that require goes to 2.1 sometime soon. But it may not, and I'm not entirely certain how to point Mimosa at non-npm published code.

In the short-term I'll comment out the urlArgs param in the main.coffee you get delivered and open a bug here to track it.

@Coneko
Copy link
Author

Coneko commented Aug 13, 2012

Yes, that's what it is, no problem then.

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