@oazmi/superbuild - v0.3.2
    Preparing search index...

    Interface OnEmitOptions

    interface OnEmitOptions {
        filter: RegExp;
        inputs?: OnEmitOptions_InputFilter[];
        importedBy?: OnEmitOptions[];
    }
    Index

    Properties

    filter: RegExp

    a filter for the output filename of a file that is to be emitted.

    Note

    when a resource is re-emitted with an updated OnEmitResult.path, this filter will test against the updated OnEmitResult.path, rather than the original/initial output path.

    a filter for specifying which input resources should be part of what constitutes this output file.

    for instance, if one were to bundle entrypoints A and B, and A depended on X and Y, while B depended on Y and Z, then the emitted bundled file corresponding to entrypoint A will have all three A, X, and Y show up in its inputs array. similarly, the emitted bundled file corresponding to entrypoint B will have all three B, Y, and Z show up in its inputs array.

    when multiple input filters are specified, they (the filters) will all need to be satisfied simultaneously (logical AND) by the list of available OnEmitArgs.inputs of the emitted resource. for instance, for the scenario mentioned prior:

    • if inputs = [{ filter: /A/ }, { filter: /Y/ }], then the emitted file corresponding to entrypoint A will be matched, but not B (since it has no input with the name A).
    • if inputs = [{ filter: /Y/ }], then the emitted files corresponding to both entrypoints A and B will be matched (since they both incorporate the dependency file Y).
    • if inputs = [{ filter: /Y/ }, { filter: /Z/ }], then only the emitted file corresponding to entrypoint B will be matched, and not A (since A does not incorporate the dependency file Z).
    importedBy?: OnEmitOptions[]

    a filter to recursively describe what your emitted resource is getting imported by. in essence, this filter lets you perform a look ahead, before you miss intercepting an emitted output, and only realize after the fact, once you reach a certain dependent file (and consequently being prohibited from modifying the contents or output path of the dependency file).

    if you provide multiple filters inside, then it will act as an AND clause; meaning that:

    • at least one of the importers of this entity should satisfy the importedBy[0] filter,
    • AND at least one of the importers of this entity should satisfy the importedBy[1] filter,
    • AND at least one of the importers of this entity should satisfy the importedBy[2] filter,
    • AND so on and so forth.

    if you want to intercept all emitted js-files that are being dynamically imported by files that originated from an input that used an "html" loader, then you would declare your filter as such:

    my_js_filter: OnEmitOptions = {
    filter: new RegExp("\\.js$"),
    importedBy: [{
    filter: new RegExp(".*"),
    inputs: [{ filter: new RegExp(".*"), loader: "html" }],
    }],
    }