Skip to content

Handling additional transform arguments #19

@rreusser

Description

@rreusser

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions