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

Users should not load files under "/internal"

Macros and Functions

declaration_info

Constructs a DeclarationInfo including all transitive files needed to type-check from DeclarationInfo providers in a list of deps.

declarations

list of typings files

deps

list of labels of dependencies where we should collect their DeclarationInfo to pass transitively

js_ecma_script_module_info

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

Returns a single JSEcmaScriptModuleInfo.

sources

deps

js_module_info

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

Returns a single JSModuleInfo.

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.

sources

deps

run_node

Helper to replace ctx.actions.run

This calls node programs with a node_modules directory in place

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

DeclarationInfo

The DeclarationInfo provider allows JS rules to communicate typing information. TypeScript's .d.ts files are used as the interop format for describing types. package.json files are included as well, as TypeScript needs to read the "typings" property.

Do not create DeclarationInfo instances directly, instead use the declaration_info factory function.

Note: historically this was a subset of the string-typed "typescript" provider.

DirectoryFilePathInfo

Joins a label pointing to a TreeArtifact with a path nested within that directory.

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

JSModuleInfo

JavaScript files and sourcemaps.

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.

LinkablePackageInfo

The LinkablePackageInfo provider provides information to the linker for linking pkg_npm built packages

NodeContextInfo

Provides data about the build context, like config_setting's

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.