Description
So, I started using gobble more (btw, it's really great!), and discovered a couple of things I'd like to discuss.
Because of Ractive components, I use inline scripts and styles very often. Since I wanted to be able to use ES6, I wrote a small script which extracts content of <script>
elements from html files, transforms it with babel, and writes ES5 code back to the html file.
I wanted to submit a PR to babel/gobble-babel, but then I realized we'd need to know the file name (to determine whether we're dealing with a js or html file), and an ability to set the file extension from within the transformer. Is seems the file name is available as this.src
, but I haven't found a way to change the extension.
The question is if it wouldn't be better to have another gobble plugin to deal with inline scripts, but that would effectively mean writing all js and css transformers and checkers (you might want to lint your inline scripts too!) twice. I think that would be a hell to maintain for both plugin authors and consumers, not to mention that two different plugins doing almost the same thing could have different APIs.
Since file transformers can already return an object with the code and a source map, I was thinking if adding ext
to this object to change the file extension for the current file would make sense.
Also, while writing plugins for jshint and jscs, I was wondering if having file observers wouldn't be useful to prevent linting files that didn't change.