browserify / watchify

watch mode for browserify builds
Other
1.79k stars 181 forks source link

Skip temp file #172

Closed zertosh closed 9 years ago

zertosh commented 9 years ago

Using a dot file in the same dir as the outfile causes problems like https://github.com/substack/watchify/issues/140 https://github.com/substack/watchify/issues/154.

Using the system tmp dir and then renaming doesn't work across partitions https://github.com/substack/watchify/issues/171.

Despite https://github.com/substack/watchify/pull/161/files#issuecomment-84511330 ("[the] feature was added in the first place to protect against delivering incomplete, partial content"), we should try not using an intermediate file. This how browserify already works when you use its --outfile option. I would argue that receiving incomplete/partial content because the user didn't wait is no more egregious than writing out to the file a console.log(JSON.stringify(err)); - since incomplete content will almost certainly be syntactically invalid and thus would error if used.

zertosh commented 9 years ago

@substack If you get a chance, please chime in on this. I'll hold off a day before merging.

mattdesl commented 9 years ago

What about using a module like tmp?

In budo I have had to jump through some hoops to get tmpfiles deleted correctly in OSX. Such as handling SIGINT (Ctrl + C). Otherwise the OSX temp dir just starts bloating (I'm not sure when/if OSX ever cleans it automatically?). I can't speak to Linux/Windows.

mattdesl commented 9 years ago

oh.. i am dumb, it looks like this is removing the temp stuff which is good :+1:

zertosh commented 9 years ago

@mattdesl Want to put together a quick PR for opts.poll || typeof opts.poll === 'number' so I can merge that and this?

zertosh commented 9 years ago

Actually, skipping the temp file makes a lot sense. I was just trying to implement a solution to https://github.com/substack/watchify/issues/16 using outpipe, and the temp file is getting in the way.

I'm going to merge this and publish it as 3.0.1. Then, follow up with a 3.1.0 that incorporates outpipe so you can do:

watchify main.js -o 'exorcist public/main-built.js.map > public/main-built.js' -v -d
# or
watchify main.js -o 'uglifyjs -cm > public/main-built.js' -v