javascript_dependencies

Expand a frozen native JavaScript lockfile into content-pinned package fetches and one node_modules layout per workspace member.

This graph-owned kind replaces the earlier whole-install JavaScript target. It never dispatches to npm ci, pnpm install, Yarn install or Bun install. The separate react_native_dependencies kind uses the same graph-owned packages and adds selected React Native and Hermes identities. Neither kind falls back to a native installation.

toml
[[target]] name = "dependencies" kind = "javascript_dependencies"

Declare this target beside the workspace's package.json. Set the lockfile attribute if the workspace contains more than one lockfile. The supported formats are pnpm v9, npm v2/v3, Yarn Classic, Yarn Berry metadata v6/v8/v10, and Bun text v1/v2. Berry requires a committed cache and a node-modules or pnpm linker.

Berry layouts include a deterministic native node_modules/.yarn-state.yml locator map. It contains only sorted relative package locations, without checkout paths or timestamps, so native Yarn can find dependency binaries. Consumers running Yarn scripts must include their native yarn.lock and credential-free .yarnrc.yml in srcs; the volatile .yarn/install-state.gz is reconstructed in private runtime state rather than copied from the checkout. Both supported layouts use Yarn's node-modules execution linker with this map.

Building this target fetches and assembles all workspace members. To start a build without waiting for unrelated members, depend on the generated member layout instead. The root layout is node_modules; use struo query targets to find other members.

javascript_build consumes the generated member layout, not this aggregate dependency target. The portable javascript-locked-package starter demonstrates the root node_modules target.

Native-installer attributes allow_network, install_args, package_manager, package_manager_executable, package_manager_files, package_json, npmrc and node are unsupported on this owner. Supplying one produces an actionable javascript.native_install_attribute diagnostic rather than ignoring it or falling back to an installer. Use the root package.json, lockfile, and the supported native configuration files. Select Node on the build or layout target. Local directory and Git dependencies remain unsupported on this graph path. Integrity-pinned archives may use relative file: URLs beside the owner manifest.

Dependency lifecycle builds#

Fetched package trees remain immutable. Generated javascript_package_build targets create private dependency contexts and run approved preinstall, install and postinstall hooks in that order. A package build waits for its own dependency builds, not unrelated packages or members. Cyclic packages share one component and run in stable package-key order; a cycle cannot assume another member has already generated its outputs. The final layout consumes completed package outputs, including generated files. Components without approved hooks reuse content-keyed materialization outputs. Actual hook execution is uncached: Node and shell identities alone do not capture arbitrary runtime tools invoked by dependency code. Archive acquisition and final layout actions remain content-keyed, but no target may skip a required lifecycle execution using an earlier outcome.

Approved hooks run with a read-only original workspace, denied network access and writable private scratch. Unsupported confinement fails closed. Packages without approved hooks use ordinary materialization and cannot execute hooks. Fetched manifests are restored before dependent analysis selects that path. Confined builds publish a regular tar archive through the parent process, then bounded extraction validates its contents and preserves contained relative links. The archive writer is an observed tool; it does not resolve dependencies.

Root and linked workspace hooks remain unsupported: their ordering, generated source ownership and tool inputs are not modeled. Affected declarations receive javascript.lifecycle_scripts diagnostics before layout publication. This includes npm root preprepare and postprepare, pnpm workspace preprepare and postprepare, pnpm root pnpm:devPreinstall, and Bun root preprepare and postprepare, alongside the install and prepare hooks already checked. These declaration checks are conservative even when script suppression is set.

Workspace binding.gyp detection produces javascript.implicit_node_gyp rather than silently omitting an automatic native build. npm's gypfile: false disables its automatic detection; this flag is not assumed to disable pnpm's native behavior. Creation of a previously missing binding.gyp invalidates loading evidence. Dependency components preflight all their own packages before running any of their hooks. Unsupported automatic builds emit a structured struo.diagnostic.v1 payload with the component target, deps attribute and repair instructions in the action failure. This runtime payload does not change the CLI's outer action-failure error code or introduce a global scheduling barrier. Suppressed dependency builds remain skipped. Node-gyp execution requires declared native tools and outputs; no native installer is used as a fallback.

npm and Yarn Classic honor ignore-scripts in the root .npmrc; Classic also honors its .yarnrc setting. Berry honors enableScripts and root dependenciesMeta.built. pnpm supports explicit onlyBuiltDependencies, neverBuiltDependencies or Boolean allowBuilds, with exact versions or exact version alternatives. Effective script suppression disables even approved builds. pnpm also honors ignore-dep-scripts in .npmrc. For pnpm 10.34.9, Boolean ignoreScripts and ignoreDepScripts in pnpm-workspace.yaml independently override the corresponding .npmrc settings. Either effective setting disables dependency hooks. Pin packageManager to pnpm@10.34.9 to use these workspace settings; other versions reject until their precedence is verified. Early pnpm 10 releases do not apply this workspace precedence. Script suppression in package.json#pnpm and approval lists in .npmrc still reject explicitly; use .npmrc or the verified pnpm workspace manifest for suppression, and the workspace manifest or package.json#pnpm for approvals. Pin packageManager to distinguish pnpm 9's permissive default from pnpm 10's approval requirement. Bun requires explicit trustedDependencies when packages have hooks; its version-specific built-in trust list is not yet modeled. Bun's Boolean install.ignoreScripts in bunfig.toml disables even explicitly trusted hooks. An explicit pnpm neverBuiltDependencies: [] permits all dependency hooks; a nonempty list skips the listed packages. A missing or null denylist retains the pinned manager's default approval policy. Script suppression still overrides an empty denylist. Values other than a list of package strings or null reject. Workspace neverBuiltDependencies requires the verified pnpm@10.34.9 pin; other versions reject this workspace policy rather than authorizing hooks that older native releases would ignore. Root package.json#pnpm.neverBuiltDependencies remains supported separately, including for pnpm 10.0.0. External approval files and dangerouslyAllowAllBuilds remain unsupported.

Required linked workspace source files are inputs to the package build, so changing them invalidates generated outputs. Unrelated members, existing node_modules, Struo state and credential configuration are not staged there. Source symlinks are not followed. Package-internal relative output links are retained; absolute links and links escaping a package fail instead of becoming dangling links in a different final layout.

Root/workspace lifecycle hooks, implicit node-gyp builds, external pnpm approval files and unrestricted build approvals remain unsupported. Hook actions request network denial, use private HOME and include Node, shell, OS and architecture in their identity. This is not a hermetic native compiler toolchain: arbitrary host tools invoked by a script are not modeled, so lifecycle execution cannot certify hermetic replay. The current context representation is capped at 100,000 materialization records per dependency owner and rejects larger expansions explicitly.

The experimental deferred-graph integration also supports pnpm, npm, Bun, Yarn Classic and Berry registry resolution without a preexisting lock:

toml
[[target]] name = "dependencies" kind = "javascript_dependencies" [target.attrs] lockfile = "pnpm-lock.yaml" resolution = "update" metadata_generation = "refresh-1"

For Yarn Classic, set lockfile = "yarn.lock". Classic workspaces use native compatible version ranges to link local members, not the workspace: protocol. For npm, set lockfile = "package-lock.json". Updates preserve version 3; version 2 locks remain available in frozen mode. Existing compatible positions and pins are retained. New packages use nested positions rather than global hoisting, so unrelated members can settle independently.

For Bun, set lockfile = "bun.lock". Updates preserve native text lock v1/v2 tuples and compatible positions. New choices use nested positions. Peers, bundles, overrides, package extensions, catalogs, patches, trusted lifecycle builds, dependency-class collisions and prerelease ranges fail explicitly; exact prereleases and tags are supported. Update mode rejects installation configuration in bunfig.toml.

Each metadata generation identifies an authorized registry refresh. Reuse it to replay cached observations, including from a remote cache; change it to request fresh metadata. Version selection and native lock encoding run in Starlark. The proposed lock is a build output of js.lockfile, never an implicit source write. Independent member closures become runnable before unrelated members finish resolving.

For Berry, use packageManager: "yarn@4.19.0", a node-modules or pnpm linker, compressionLevel: 0, and set berry_yarn to the installed Yarn 4.19.0 CLI JavaScript file. Struo selects npm/workspace descriptors in Starlark. It uses Yarn only to encode each integrity-verified archive into the native cache ZIP and checksum. Updates preserve metadata version 10; frozen mode also reads versions 6 and 8. Berry update mode rejects peers, platform conditions, package extensions and installation overrides.

Registry observations require a cache provider with atomic conditional creation. Local caches and shared filesystem object stores support this contract. HTTP and Tuist cache providers currently reject these observations; they remain usable for frozen, integrity-pinned package acquisition. Builds emit a source proposal with exact manifest/configuration preimages and workspace discovery guards. Apply it explicitly with struo edit sources; neither builds nor cache restoration write native source locks.

This path does not support every native resolution option. Yarn Classic updates reject contextual peers, resolutions, flat mode, nohoist, installation configuration overrides and Yarn configuration files. Only public registry mappings are accepted in its .npmrc. npm also rejects peers, overrides, acceptDependencies, devEngines and bundled packages. pnpm updates reject hook files/configured hook paths, disabled autoInstallPeers, enabled linkWorkspacePackages or preferWorkspacePackages, and unsupported peer/link policies in workspace YAML or .npmrc. Retained nondefault peer settings are rejected too. Adding a hook after resolution invalidates source publication, so an earlier proposal cannot bypass the hook policy. Unsupported sources, patches and lifecycle builds are rejected instead of delegated to a native resolver, including Yarn Classic's root prepublish hook. If a retained Yarn version disappears from refreshed registry metadata, update mode fails explicitly instead of changing the pin. Its existing frozen lock remains usable. See the JavaScript workspace contract for limits, layout behavior and cache semantics.