benbria / browserify-transform-tools

Utilities for writing browserify transforms.
MIT License
65 stars 15 forks source link

Not able to programatically specify what file extensions are included #16

Closed matthewdunsdon closed 8 years ago

matthewdunsdon commented 8 years ago

When using browserify-transform-tools (v 1.5.1), I am not able to programatically specify what file extensions to include (includeExtensions).

Partial code sample:

var DEFAULT_EXTENSIONS = ['.js']
var options = { includeExtensions: DEFAULT_EXTENSIONS }
var myStringTransform = transformTools.makeStringTransform("hello", options, function(content, transformOptions, done) {
    done(null, 'hello ' + content);
});
browserify({ entries: ['index.html'] })
    .transform(myStringTransform, { appliesTo: { includeExtensions: ['.html'] } })
    .bundle()
matthewdunsdon commented 8 years ago

Having a quick look at the code, the follow change may have caused the problem:

https://github.com/benbria/browserify-transform-tools/commit/76829faa8d65bef694ea2141e15128f150dac7c1#diff-a801f5af448ba06bc6096727b57fa60eL58

matthewdunsdon commented 8 years ago

I have not used coffeescript on a regular basis and am not sure if this is the correct place (in the code) to make the fix, so I have only created a reference commit (rather than a PR) showing sample fix and proposed test changes:

https://github.com/matthewdunsdon/browserify-transform-tools/commit/ec9e7b0f2fac3

jwalton commented 8 years ago

Thanks for tracking this down so quickly! I'll have a look at your fix tomorrow morning. On Feb 16, 2016 8:57 PM, "Matthew Dunsdon" notifications@github.com wrote:

I have not used coffeescript on a regular basis and am not sure if this is the correct place to make the fix, therefore I have created a reference commit (rather than a PR) showing sample fix and proposed test changes:

matthewdunsdon@ec9e7b0 https://github.com/matthewdunsdon/browserify-transform-tools/commit/ec9e7b0f2fac3

— Reply to this email directly or view it on GitHub https://github.com/benbria/browserify-transform-tools/issues/16#issuecomment-184972623 .

jwalton commented 8 years ago

Published as 1.5.2. Thanks @matthewdunsdon! I used almost exactly your fix.

matthewdunsdon commented 8 years ago

Looking at this further, I am not sure this quite solves all the edge cases. I have created PR #17 to address this.