Pre-bundle vendor (node_modules) dependencies for dev mode.
Scans source files with OXC.select/3, identifies bare specifiers
(non-relative, non-URL), resolves them through module directories, and
bundles each into a single ESM file with OXC.bundle/2.
CJS packages (e.g. React) are automatically converted to ESM during
bundling. process.env.NODE_ENV is replaced with "development"
so conditional CJS branches resolve correctly.
Bundled files are cached on disk in _build/volt/vendor/.
Vendor URLs carry a version, ?v=, that browsers cache them under for
good. It changes with the module directories, lockfiles and plugins, and
with the generation of the pre-bundle: a hash over the signature of every
package bundled, written beside the bundles. A package that changed in
place, such as a linked one, is bundled again on the next pre-bundle, which
gives every vendor module a new URL. One URL for all of them is deliberate:
the bundles share chunks, and a browser mixing old and new ones would hold
two instances of a chunk.
Summary
Functions
Return the current browser hash for optimized dependency requests.
Bundle a single vendor specifier on demand.
Return whether a request browser hash matches the current optimized dependency state.
Decode a URL-safe specifier back to its original form.
Encode a specifier for use in URLs (escaping @ and /).
Return the generation of the pre-bundle for opts: a hash over the cache
signatures of the packages bundled, or nil before the first pre-bundle.
Scan source files and pre-bundle any bare npm imports.
Read a pre-bundled vendor file by specifier.
Read a pre-bundled vendor file when its cache signature matches the current options.
Get the URL path for a vendor module.
Get the URL path for a vendor module with a cache-busting browser hash.
Functions
Return the current browser hash for optimized dependency requests.
The hash covers the browser signature and the generation of the pre-bundle, so it changes when a package is bundled again.
@spec bundle_on_demand(String.t(), String.t() | nil, keyword()) :: {:ok, String.t()} | {:error, term()}
Bundle a single vendor specifier on demand.
Used by the dev server when a /@vendor/ request arrives for a
specifier that wasn't caught by prebundle/1 (e.g. transitive
dependency, or newly added import).
Return whether a request browser hash matches the current optimized dependency state.
Decode a URL-safe specifier back to its original form.
Encode a specifier for use in URLs (escaping @ and /).
Return the generation of the pre-bundle for opts: a hash over the cache
signatures of the packages bundled, or nil before the first pre-bundle.
Scan source files and pre-bundle any bare npm imports.
Returns a map of specifier → vendor_path for import rewriting.
Options
:root— source directory to scan:node_modules— path to node_modules (default: auto-detect):resolve_dirs— additional package directories to resolve from:force— rebuild even if cached (default:false)
Read a pre-bundled vendor file by specifier.
Read a pre-bundled vendor file when its cache signature matches the current options.
Get the URL path for a vendor module.
Get the URL path for a vendor module with a cache-busting browser hash.