broccolijs / broccoli-persistent-filter

MIT License
12 stars 33 forks source link

Rejecting / Excluding Files | broccoli-funnel #172

Open buschtoens opened 5 years ago

buschtoens commented 5 years ago

Now that we have Dependency Tracking #168, this plugin becomes much more interesting for bundler-liker build scenarios, where n files get merged into 1 or fewer than n files.

It would be nice, if broccoli-persistent-filter could add a hook to reject a file from the build (similar to getDestFilePath), removing the need for a subsequent broccoli-funnel.

stefanpenner commented 5 years ago

And this is specifically to reject/exclude input files right?

If so @SparshithNR's https://github.com/SparshithNR/fs-merger may fit the bill for broccoli-persistent-filter to use, instead of direct this.inputPaths access.

SparshithNR commented 5 years ago

I am trying to integrate the https://github.com/SparshithNR/fs-merger, so that broccoli-persistent-filter will accept n trees/paths as input and process it and put processed files to the output path. This will avoid the funneling/merging multiple trees before sending it as an input to the broccoli-persistent-filter. Something like

class FileModifier extends BroccoliPlugin {
  constructor(nodes, options = {}) {
     super(nodes, {
        name: options.name,
        annotation: options.annotation,
        persistentOutput: true
      });
}

Here nodes is a list of trees or inputPaths from previous step.

chriseppstein commented 4 years ago

@stefanpenner It seems to me that what is being requested is an option that causes only files processed by the filter to pass through to the output tree. @buschtoens is that sufficient?

vitch commented 4 years ago

@chriseppstein @stefanpenner - I've come across this issue as I am just starting to use broccoli-persistent-filter and I have a need to do just that.

I guess I could funnel beforehand but I do want some of the other files to be in the tree/ watched as I need to read from them in processString and include information from them in the output file (I'm still working on it but I'm planning to use setDependencies to help with the caching). So maybe I'll end up funneling after but I'm not sure if that will result in unnecessary work being done?

chriseppstein commented 4 years ago

@vitch Yeah, I think you'd have to funnel after filtering in that case, it's a little extra work, but not a ton (the files are just symlinked).