documentify icon indicating copy to clipboard operation
documentify copied to clipboard

Handling additional transform arguments

Open rreusser opened this issue 8 years ago • 1 comments

html-inject-script, to name one example, exposes a transform function that accepts two arguments. Documentify is currently only capable of passing one argument. If you configure a transform like this:

"transform": ["html-inject-script", "bundle.js"]

It's invoked as htmlInjectScript("bundle.js"). Passing additional arguments would either look like this:

"transform": ["html-inject-script", "bundle.js", {"foo": "bar"}]

which would be invoked as htmlInjectScript("bundle.js", {"foo": "bar"}), which seems weird because the configuration has multiple arguments in parallel with the transform name. A breaking change would be for configuration to require array-wrapping all arguments always:

"transform": ["html-inject-script", ["bundle.js", {"foo": "bar"}]]

This is my favorite option since it's easy enough to infer that it's just running .apply(null, args) on the transform, though the single-argument case is a bit clumsy.

The third option is that all compatible transforms must only take one argument.

Thoughts on the best path forward?

rreusser avatar Nov 18 '17 22:11 rreusser

@rreusser I'd go with whichever syntax browserify is using; the less there's to learn, the easier it is C:

yoshuawuyts avatar Nov 21 '17 13:11 yoshuawuyts