Change:
}, "dependencies": { "base62": "~0.1.1", <del> "commoner": "~0.8.0", </del> <ins> "commoner": "~0.8.3", </ins> "esprima": "https://github.com/facebook/esprima/tarball/a3e0ea3979eb8d54d8bfade220c272903f928b1e", "recast": "~0.4.8", "source-map": "~0.1.22"

Discussion:
Basically what the title says. After install react-tools, using jsx -w <srcdir<destdirwill correctly detect existing files (but not transform them), and upon any write to any watched file jsx will exit with error code 1. Commoner tests all pass. Exact steps I followed, in Ubuntu 12.10: 0) Install via manual instructions at for Ubuntu/Mint 1) Install react-tools with 'sudo npm install -g react-tools' 2) Create file in <src, as described by the Getting Started tutorial. 3) In a new terminal, jsx -w <src<dest4) Edit and add a comment. 5) Notice that jsx exited, echo $? prints 1. akrieger ls js/ akrieger ls html/js/ akrieger jsx -w js/ html/js/ ["helloworld"] <edit , save editakrieger 1 akrieger ls html/js/ akrieger
Hypothesis: The only thing that keeps commoner from exiting in mode right now is the option passed to . That means the process will stay alive while there are any files left to watch. But some text editors save files by deleting and then re-writing them, which causes to un-watch the file (because the original inode that inotify cared about got discarded). When there's only one file, unwatching it causes Node to think no files need to be watched, so the process exits. cc
Opened a new Commoner issue: Even though said the Commoner tests pass for him, that's only because mode test coverage is… lacking. :frowning:
That didn't seem to work for me, unless the file is supposed to be a valid JSX file with something to transform.
It also doesn't solve the issue that jsx doesn't seem to be doing any static transformation anyway, even in the example getting started tutorial.
That's another regrettable but known issue: I suspect you're missing the comment at the top of the file (which won't be necessary soon, but currently is still important). cc
I copy pasted the sample code exactly: <code/ React.DOM */ React.renderComponent( blah blah );</code
Just to try something else: can take a single file name on the command line: . Does that also not show any transformations? Or did you try that already?
bin/jsx does the right thing.

Furthermore, if I have a file named in the destination directory, it is deleted when I try to run jsx on the source and dest directory, in either watch or go mode.
The deletion is by design, at least. The files that end up in the output directory are actually hard-linked with master versions that are kept (by default) in . Each build unlinks and then relinks the files in the output directory, so if the relink fails it will look like the file was just deleted. Not sure why the relinking might be failing. In case is on a different device from , you could try relocating the cache:
Yeah, they are on different devices. Moving the cache dir worked. Thanks!
Accidental close, sorry. Still need to mitigate that cache dir problem.
How important is the cache behavior? Could we disable it? I'd trade perf for ease of use with this tool
:thumbsup: to what said. I'd also take defaulting the cachedir to the src/current dir (I think this is how sass does it's cache)
pretty important; the incremental speedup is significant for a codebase the size of It's a one-line change to switch the default location, and it won't break anything for anyone. Kicking myself now because I actually considered whether ~/.commoner was likely ever to be a different device, and clearly I guessed wrong :(
I wonder if the requirements that we need for the react codebase are the same as those for end users. I think most people just want a simple syntax transform and watcher ala coffee script.
Also +1 on just moving the cache dir :)
true, but I don't think we can pretend that is a fully-featured source transform tool if it doesn't do any caching (coffeescript and sass clearly suggest that caching is worthwhile for enough people) The original location of the cache directory was , but I moved it when I support for printing the transformed code to STDIN, in which case there's no . Definitely okay with skipping the cache logic in that case.
So I've been looking through various implementations of Dir watchers (gaze, chokidar) in NodeJS and they're all pretty clowny - a pretty easy test case that breaks them is making a new directory and adding files to that directory.

So since someone on the internet was wrong, I wrote another FS watcher last night that I think is way more stable: I'll try to merge this new file watcher with the transformer I made a couple days ago () and see what happens just as proof of concept. - I'll probably have something for you to play w/ in an hour or two =]
I had pretty good results with a makefile and running make every 2s :P
now you're trolling me :P
I can't wait.
Not trolling; it's very reliable and easy to reason about. Is comparing file mtimes to determine if they need to be rebuilt bad relative to a module cache?
give a shot - still a work-in-progress, but lmk how it goes
Dear Your question deserves a careful response. I know this looks long-winded, but if you read it through you'll know everything that I was thinking. The primary virtue of the module cache is that the cache filenames are hashes of all the relevant input variables: source, module name, build steps, configuration properties, Commoner version, and more. Change any one of those input variables and you get a different hash. If you find a file called in the module cache, you can be completely certain that the cached file contains the right contents. I believe that's a useful guarantee. A secondary benefit is that old versions of a file don't go away just because the file was recently rebuilt. If you revert a file to a version that has ever been built before, you don't have to rebuild it again. In order to make the same promise under the strategy, you'd have to find some way of storing all those distinct versions, and I'm confident the method you would come up with would closely resemble my hashing strategy. It's what every sensible version control system does. The goal of both strategies is to determine whether you can trust the contents of a file that was built some time in the past. This decision is completely reliable under a hashing strategy, and if it ever fails then there must be some additional piece of information that you neglected to incorporate into the hash. None of the bugs that I've fixed in Commoner had anything to do with module cache inconsistency. When's the last time you had to wipe your module cache? And no, doesn't qualify, because I made sure it left the cache untouched.

With that background, let me answer your orginal question: "Is comparing file s to determine if they need to be rebuilt bad relative to a module cache?" Yes, because the only input variables considered by the strategy are (name of source file, of source file), which allows you to avoid rebuilding the file if corresponding output file has a later , and know no other input variables have changed in the meantime, such as build steps, configuration properties, new files /removed whose presence/absence affects the build, independent build processes racing to update files in the output directory, etc. Requirement 1 is too strong because you don't necessarily have to rebuild source files that appear newer than their output files (see my second paragraph above). Requirement 2 is too strong because you don't have to "know" any of those things if they can be accounted for automatically, as they are under the hashing strategy. Is the strategy good enough? Maybe it is for you, because you know how to spot signs of inconsistency and you have trained yourself to predict when a is finally necessary. I don't think we can expect the same of new users of React. They're much more likely to attribute subtle problems to the library itself instead of guessing that the build tool messed up. Sometimes we reinvent the wheel just so that we know exactly how the wheel we're using works, quirks and all. I'm guilty of this myself, but in my defense I really am trying to get us to a point where we don't have to make any apologies at all for the way our tools work. I know there are still bugs in Commoner, but I'm committed to squashing all of them.
I'm not hating on commoner. It's an excellent CommonJS build system and is totally the right choice to build react and any jsx project that uses CommonJS modules with transforms. The problem is that users think it is a simple syntax transform (like coffee?) when in reality it doesn't behave that way. Specifically it assumes that everything you're desugaring is a CommonJS module and it assumes specifics of the implementations path resolution methods, which in requirejs, browserify and haste are all different, by relativizing. If you aren't using CommonJS and define your own unrelated require() function the arguments will get rewritten, weird missing module warnings will fire and fake modules will be created.

It's actually really freaking awesome to have this tooling for CommonJS projects but really confusing if you're not in a CommonJS project or using a different module resolver. Some of the annoyances we've with r.js are because it tries to be too clever in this area (we have eval('req'+'uire')(...) somewhere in the insta codebase because of this). As a user since I know jsx is willing to rewrite my code I find it hard to predict exactly how it will transform. What if instead jsx had a --relativize option that we disabled by default and it just treated everything like a file and transformed it, either with a cache or based on mtime? We'd continue to use the option on react itself and perhaps even advertise commoner+a browser packager (brigade?) as our recommended module system since they'll likely want debranching and other goodies even though they don't know it yet :)
The original issue still needs fixing, by the way. Still working on that.
One of the reasons I was not able to get the jsx transformed files was I didnt close the terminal window first time after installation. I closed the terminal window and re-opened it again and then I was able to transform any JSX file located anywhere on my disk to any folder. :) possible solution.

Trying to run jsx to build into a subdir seems to just exit with no error message: (public/js does exist) However, if run in directly in public it works without a hitch:
Are there any files in yet? Also potentially useful: what are you running, and what OS?
There is a file in src which builds when not using a subdir in the public dir. node version is 0.8.23 and im on OS X Mountain Lion
Installed 0.8.23 but no luck reproducing. Will try on a Mountain Lion machine tomorrow. Thanks for the report. Do you see this failure with an empty file? If using an empty file makes the failure go away, perhaps you can try cutting out different parts of the file to figure out the minimal contents that trigger the failure? It could be a problem with on Mountain Lion, though. That's my hunch.
One more idea: the module cache might have gotten into a bad state somehow. Try clearing it by deleting the directory ?
The same file builds fine if I use (note the lack of public/js). Deleting that directory didn't work for me.
I know this is still broken. Still working on a fix.
:heart:
I had same problem on ubuntu. Yesterday "jsx --watch" worked just fine for me. Today when I ssh-ed again and ran "jsx --watch reactjs/ js/" it just silently does nothing.
- I was having issues w/ vim file writes not being caught so I hacked together - Feel free to try it and let me know if it works (Haven't had the time to test on Ubuntu yet...) - We might use the file watcher in that repo in Commoner / JSX in the future.
:+1: Work like a charm. Thank you very much!
Ok. I think I now know what the issue is. jsx created a file in the output directory. If that file is still there when running jsx again it will quick silently.
Awesome!