thlorenz/es6ify

Suggestion for API options

Opened this issue · 3 comments

Small suggestion, I think it would be simpler to allow passing in the traceur options into the es6fy method, e.g.

browserify()
  .transform(traceurify({ blockBinding: true }))
  .bundle()

Also it would be nice to pass in the runtime as an option.

browserify()
  .transform(traceurify({ runtime: true, blockBinding: true }))
  .bundle()

Thanks for these ideas, but unfortunately putting these in practice is not easily done, especially when these two requirements need to be met:

  • es6ify needs to be usable as a pure browserify transform
  • any API change should be backwards compat

As outlined before the es6ify function itself needs to stay the same since only that way does it satisfy the signature that browserify assumes from a transform.

We could how ever adapt es6ify.configure to handle an options object instead of only a regex.

So it'd be es6ify.configure({ filePattern: /../, traceurOverrides: { .. }}.

Also it would be nice to pass in the runtime as an option

Not really possible since to add it es6ify would need to have access to browserify which it doesn't.
This idea was discussed at length with the conclusion that adding it manually is the best option for now.

Pull request that supports:

  • pure browserify transform
  • backwards compatibility

However, I did this quickly so I might've missed something, it's mostly a proof of concept.

The runtime option is indeed tricky, I do have an idea I want to try before giving up.

Added the runtime option PR, that is built on top of the previous PR.
It is working, but I do feel that it needs a good touch of refactoring.