jsdf / browserify-incremental

incremental rebuild for browserify
175 stars 13 forks source link

Changes to imported less files doesn't cause cache miss #12

Closed ropez closed 9 years ago

ropez commented 9 years ago

When used with lessify

Changes to less files included in an @import statement doesn't cause the output to be updated. You have to touch the main less file to trigger an update.

Example:

# main.less
@import "foo.less";

# foo.less
body { background: blue }

# main.coffee
require('main.less')

When a cache exists, chaning foo.less doesn't cause the resulting CSS in main.coffee to change. I have to run touch main.less to cause an update.

jsdf commented 9 years ago

Thanks for reminding me of this

relates to https://github.com/jsdf/browserify-incremental/issues/2

jsdf commented 9 years ago

Okay firstly for this to work, lessify would need to emit a 'file' event for each less file which is required from a particular module (js/coffee/etc file) and all of its less imports. The brfs transform has an example of this.

ropez commented 9 years ago

No problem.

Is there anything I can do to help. Check if this can be done in lessify, and do a PR if necessary?

jsdf commented 9 years ago

Yep, that would definitely help.

ropez commented 9 years ago

I figured it should be as simple as this: https://github.com/snaptv/lessify/commit/f6ee2d68811a4a428859d56ce78012536fe4ded6

Do we actually need to emit an event for each imported file, or can we allow the argument to contain the whole array in a single event? I'm not very familiar with the API, I'm not sure if there's an "official" spec for this 'file' event.

I haven't sent a PR yet, waiting for feedback here first.

(btw, I found out there are two lessify modules, node-lessify and lessify. I'm using the latter, not the one I linked to in the original post)

jsdf commented 9 years ago

The 'spec' is 'whatever watchify does', which you can see here. browserify-incremental fulfils the same role as watchify here, and lessify would be doing the equivalent of brfs. watchify and brfs are written by @substack – that's about as close as there is to a spec for this particular mechanism.

ropez commented 9 years ago

Ok, I've tested this patched lessify with watchify, and it does the trick. I'm sending a pull request to lessify.

ropez commented 9 years ago

So, the missing pieces have now been merged:

https://github.com/dstokes/lessify/pull/7 https://github.com/jsdf/browserify-cache-api/pull/1

What remains to be able to use this feature is to update the dependency here, and publish new versions to npm. I don't think I can PR tagging and uploading, any chance of a new version in the nearest future?

jsdf commented 9 years ago

published 3.0.0

ropez commented 9 years ago

Thank you