Public providers, aspects and helpers that are shipped in the built-in build_bazel_rules_nodejs repository.

Note that many providers have moved to the rules_nodejs "core" package. See Core API doc

Users should not load files under "/internal"

Macros and Functions

js_ecma_script_module_info

Constructs a JSEcmaScriptModuleInfo including all transitive sources from JSEcmaScriptModuleInfo providers in a list of deps.

Returns a single JSEcmaScriptModuleInfo.

Example usage (generated)

load("@build_bazel_rules_nodejs//:providers.bzl", "js_ecma_script_module_info")

js_ecma_script_module_info(
    sources = None,
)

sources

deps


js_named_module_info

Constructs a JSNamedModuleInfo including all transitive sources from JSNamedModuleInfo providers in a list of deps.

Returns a single JSNamedModuleInfo.

Example usage (generated)

load("@build_bazel_rules_nodejs//:providers.bzl", "js_named_module_info")

js_named_module_info(
    sources = None,
)

sources

deps


run_node

Helper to replace ctx.actions.run

This calls node programs with a node_modules directory in place

Example usage (generated)

load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")

run_node(
    # rule context from the calling rule implementation function
    ctx = None,
    # list or depset of inputs to the action
    inputs = None,
    # list or ctx.actions.Args object containing arguments to pass to the executable
    arguments = None,
    # stringy representation of the executable this action will run, eg eg
    executable = None,
)

ctx

rule context from the calling rule implementation function

inputs

list or depset of inputs to the action

arguments

list or ctx.actions.Args object containing arguments to pass to the executable

executable

stringy representation of the executable this action will run, eg eg. "my_executable" rather than ctx.executable.my_executable

chdir

directory we should change to be the working dir

kwargs

all other args accepted by ctx.actions.run


Providers

ExternalNpmPackageInfo

Provides information about one or more external npm packages

JSEcmaScriptModuleInfo

JavaScript files (and sourcemaps) that are intended to be consumed by downstream tooling.

They should use modern syntax and ESModules. These files should typically be named "foo.mjs"

Historical note: this was the typescript.es6_sources output

JSNamedModuleInfo

JavaScript files whose module name is self-contained.

For example named AMD/UMD or goog.module format. These files can be efficiently served with the concatjs bundler. These outputs should be named "foo.umd.js" (note that renaming it from "foo.js" doesn't affect the module id)

Historical note: this was the typescript.es5_sources output.

NodeRuntimeDepsInfo

Stores runtime dependencies of a nodejs_binary or nodejs_test

These are files that need to be found by the node module resolver at runtime.

Historically these files were passed using the Runfiles mechanism. However runfiles has a big performance penalty of creating a symlink forest with FS API calls for every file in node_modules. It also causes there to be separate node_modules trees under each binary. This prevents user-contributed modules passed as deps[] to a particular action from being found by node module resolver, which expects everything in one tree.

In node, this resolution is done dynamically by assuming a node_modules tree will exist on disk, so we assume node actions/binary/test executions will do the same.

NpmPackageInfo

Provides information about one or more external npm packages

Aspects

node_modules_aspect

Propagates along attributes named: deps

name

A unique name for this target.