def METHOD_NAME(ctx):
    js_module_provider = _name_to_js_module_provider(ctx.attr.provider)
    transitive_mappings = []
    transitive_node_modules_roots = []
    depsets = []
    for dep in ctx.attr.deps:
        # Include JavaScript sources (including transitive outputs) based on the
        # configured JavaScript module provider.
        if js_module_provider in dep:
            depsets.append(dep[js_module_provider].sources)
        # If external NPM package sources should be included, we also capture the
        # sources (including transitive external NPM packages).
        if ctx.attr.include_external_npm_packages and ExternalNpmPackageInfo in dep:
            depsets.append(dep[ExternalNpmPackageInfo].sources)
        # If we intend to forward linker mappings, capture first-party package
        # linker mappings and collect them in a dictionary that we will re-expose.
        if ctx.attr.forward_linker_mappings and LinkerPackageMappingInfo in dep:
            transitive_mappings.append(dep[LinkerPackageMappingInfo].mappings)
            transitive_node_modules_roots.append(dep[LinkerPackageMappingInfo].node_modules_roots)
        # Based on whether declarations should be collected, extract direct
        # and transitive declaration files using the `DeclarationInfo` provider.
        if ctx.attr.include_declarations and DeclarationInfo in dep:
            depsets.append(dep[DeclarationInfo].transitive_declarations)
        # Based on whether default files should be collected, extract direct
        # files which are exposed using the `DefaultInfo` provider. Also include
        # data runfiles which are needed for the current target.
        # https://docs.bazel.build/versions/main/skylark/lib/DefaultInfo.html#data_runfiles
        if ctx.attr.include_default_files and DefaultInfo in dep:
            depsets.append(dep[DefaultInfo].files)
            depsets.append(dep[DefaultInfo].data_runfiles.files)
    sources = depset(transitive = depsets)
    return [
        DefaultInfo(files = sources),
        LinkerPackageMappingInfo(
            # Example of how linker mappings are constructed in `rules_nodejs`.
            # https://github.com/bazelbuild/rules_nodejs/blob/ae49c0e85a60234f273ea6629bc6056ab293fe5b/internal/linker/link_node_modules.bzl#L220-L222.
            mappings = depset(transitive = transitive_mappings),
            node_modules_roots = depset(transitive = transitive_node_modules_roots),
        ),
    ]