Public providers, aspects and helpers that are shipped in the built-in build_bazel_rules_nodejs repository.
Users should not load files under “/internal”
USAGE
DeclarationInfo(declarations, transitive_declarations, type_blocklisted_declarations)
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.
FIELDS
A depset of typings files produced by this rule
A depset of typings files produced by this rule and all its transitive dependencies. This prevents needing an aspect in rules that consume the typings, which improves performance.
A depset of .d.ts files that we should not use to infer JSCompiler types (via tsickle)
USAGE
DirectoryFilePathInfo(directory, path)
Joins a label pointing to a TreeArtifact with a path nested within that directory.
FIELDS
a TreeArtifact (ctx.actions.declare_directory)
path relative to the directory
USAGE
ExternalNpmPackageInfo(direct_sources, has_directories, path, sources, workspace)
Provides information about one or more external npm packages
FIELDS
Depset of direct source files in these external npm package(s)
True if any sources are directories
The local workspace path that these external npm deps should be linked at. If empty, they will be linked at the root.
Depset of direct & transitive source files in these external npm package(s) and transitive dependencies
The workspace name that these external npm package(s) are provided from
USAGE
JSEcmaScriptModuleInfo(direct_sources, sources)
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
FIELDS
Depset of direct JavaScript files and sourcemaps
Depset of direct and transitive JavaScript files and sourcemaps
USAGE
JSModuleInfo(direct_sources, sources)
JavaScript files and sourcemaps.
FIELDS
Depset of direct JavaScript files and sourcemaps
Depset of direct and transitive JavaScript files and sourcemaps
USAGE
JSNamedModuleInfo(direct_sources, sources)
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.
FIELDS
Depset of direct JavaScript files and sourcemaps
Depset of direct and transitive JavaScript files and sourcemaps
USAGE
LinkablePackageInfo(files, package_name, package_path, path)
The LinkablePackageInfo provider provides information to the linker for linking pkg_npm built packages
FIELDS
Depset of files in this package (must all be contained within path)
The package name.
This field is optional. If not set, the target can be made linkable to a package_name with the npm_link rule.
The directory in the workspace to link to.
If set, link the 1st party dependencies to the node_modules under the package path specified. If unset, the default is to link to the node_modules root of the workspace.
The path to link to.
Path must be relative to execroot/wksp. It can either an output dir path such as,
bazel-out/<platform>-<build>/bin/path/to/package
or
bazel-out/<platform>-<build>/bin/external/external_wksp>/path/to/package
or a source file path such as,
path/to/package
or
external/<external_wksp>/path/to/package
USAGE
NodeContextInfo(stamp)
Provides data about the build context, like config_setting’s
FIELDS
If stamping is enabled for this build
USAGE
NodeRuntimeDepsInfo(deps, pkgs)
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.
FIELDS
depset of runtime dependency labels
list of labels of packages that provide ExternalNpmPackageInfo
USAGE
NpmPackageInfo(direct_sources, has_directories, path, sources, workspace)
Provides information about one or more external npm packages
FIELDS
Depset of direct source files in these external npm package(s)
True if any sources are directories
The local workspace path that these external npm deps should be linked at. If empty, they will be linked at the root.
Depset of direct & transitive source files in these external npm package(s) and transitive dependencies
The workspace name that these external npm package(s) are provided from
USAGE
declaration_info(declarations, deps)
Constructs a DeclarationInfo including all transitive files needed to type-check from DeclarationInfo providers in a list of deps.
PARAMETERS
list of typings files
list of labels of dependencies where we should collect their DeclarationInfo to pass transitively
Defaults to []
USAGE
js_ecma_script_module_info(sources, deps)
Constructs a JSEcmaScriptModuleInfo including all transitive sources from JSEcmaScriptModuleInfo providers in a list of deps.
Returns a single JSEcmaScriptModuleInfo.
PARAMETERS
Defaults to []
USAGE
js_module_info(sources, deps)
Constructs a JSModuleInfo including all transitive sources from JSModuleInfo providers in a list of deps.
Returns a single JSModuleInfo.
PARAMETERS
Defaults to []
USAGE
js_named_module_info(sources, deps)
Constructs a JSNamedModuleInfo including all transitive sources from JSNamedModuleInfo providers in a list of deps.
Returns a single JSNamedModuleInfo.
PARAMETERS
Defaults to []
USAGE
run_node(ctx, inputs, arguments, executable, chdir, kwargs)
Helper to replace ctx.actions.run
This calls node programs with a node_modules directory in place
PARAMETERS
rule context from the calling rule implementation function
list or depset of inputs to the action
list or ctx.actions.Args object containing arguments to pass to the executable
stringy representation of the executable this action will run, eg eg. “my_executable” rather than ctx.executable.my_executable
directory we should change to be the working dir
Defaults to None
all other args accepted by ctx.actions.run
USAGE
node_modules_aspect(name)
ASPECT ATTRIBUTES
ATTRIBUTES
(Name, {util.mandatoryString(name: “name” doc_string: “A unique name for this target.” type: NAME mandatory: true )}) A unique name for this target.