-
-
Notifications
You must be signed in to change notification settings - Fork 15
Add importHelpers option #5
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR, I love this idea! More than a couple of times I've grumbled to myself about having I'm ambivalent about merging this PR though, because it will defeat one of gobble's most important optimisations - only re-transpiling when an input file has changed. File transformers get this for free, but that's not possible with directory transformers (currently working on a good, robust API for letting directory transformers know which changes have happened since the last successful run). Definitely worth stewing on for a while though, it'd be great to have this feature, and it might well be possible to do while keeping it as a file transformer. I've raised #6 separately for the |
Yeah, I know what you mean. The current issues with the single file transformer is:
I think that as long as a single file transformer can return undefined (no file) and the above are addressed you won't need a inputdir/outputdir transformer... [edit:] although scratch that gobble-esperanto-bundle needs to look at every file. But if we could get there you could even make the files memory bound, which would be exciting. I also wish that babel had an option to inject a babelHelpers import on files that need it. |
c81e27d
to
df330dd
Compare
df330dd
to
ca417c5
Compare
ada0bb9
to
863a6f5
Compare
@lukescott FYI I've just released 5.1.0, which at least adds
Yeah, it's a classic simplicity versus performance trade-off. I really like having 'pure' transformations - adding state into the mix feels like a quick way to guarantee bugs - but it does mean that certain things are impossible. Haven't had much of a chance to mull over this issue but I'm still keen to figure out a decent approach.
I've occasionally wondered about that. At the moment, sourcemaps are stored in memory (rather than e.g. being added as
That'd be neat. It would mean that babel would have to be aware of the source module type (couldn't necessarily assume ES6 modules), which might make things slightly more awkward. Is the runtime transformer something that could help here? I haven't really looked into it yet, but it might at least point us towards a solution. |
Re: Passing state - It would be useful within the same transformer, not necessarily between different transformers. That is if you have some sort of "final" transformer that can do something with it. It's more for adding a new file(s) at the end, whether that be concating all the files, adding helpers, or adding a source map file. Re: memory vs files - It really depends on the system. Memory will always be faster as long as you have enough of it. SSD disks can be very comparable. If the transformer only dealt with one file at a time, it doesn't have to worry about the file system. At that point you can make memory vs files configurable. Re: runtime transformer - I didn't know about that! I just tried it and it got me almost there. Unfortunately I have the following issues:
|
Adds
importHelpers
option that causes used helpers to be imported as an external file. Works well with gobble-esperanto-bundle.Example:
The
.babelrc
file is also respected (wasn't before).The only thing I haven't figured out is the map file generated by esperanto-bundle is referring to the
.gobble-build
directory.