npm & Remote Loading
Both vjs (since v0.0.0-alpha.0) and vjs-lite (since v0.0.0-alpha.1) support npm: packages, project package.json dependencies, ancestor vael.jsonc bare import maps, and remote jsr:, gh:/github:, and https: imports—without creating node_modules or running lifecycle scripts. vjs-lite implements remote and registry transport synchronously with zero Tokio or hyper via blocking ureq + rustls (unless built with --no-default-features to omit remote and npm).
Zero-node_modules npm: Packages
Section titled “Zero-node_modules npm: Packages”Import npm ESM packages directly with npm: specifiers or through the nearest package.json:
import { z } from "npm:zod@^3.23.0";import { helper } from "@my-org/internal-esm"; // via package.json dependenciesKey architectural guarantees in vjs and vjs-lite (vaeljs-npm):
- No
node_modulesdirectory: Packages are extracted into a shared content-addressed store (CAS) under$XDG_CACHE_HOME/vaeljs/packages(or$HOME/.cache/vaeljs/packages). - Content verification: Every tarball is checked against its
sha512SRI digest, extracted files are stored read-only (0444on Unix) by SHA-256, and reads verifyO_NOFOLLOW, file length, and SHA-256 in memory. - Zero install scripts or native addons:
preinstall,install,postinstall, andpreparescripts are never executed. Native and binary artifacts (.node,.dll,.so,.so.*,.dylib,.exe,.wasm) are excluded from CAS. - Strict ESM only:
exportsand#importsresolve with active conditions["import", "default"]. CommonJS (.cjsor"type": "commonjs".js) is rejected. - Offline by default: Missing packages or uncached
vael.lockentries require--allow-remote(orVAELJS_ALLOW_REMOTE=1) to fetch from the registry.
Policy Flags for npm:
Section titled “Policy Flags for npm:”| Flag | Effect |
|---|---|
--allow-remote |
Allow fetching missing npm packuments/tarballs from HTTPS registries. |
--frozen-lockfile |
Refuse any resolution not pinned in vael.lock v1 or failing integrity checks. |
--offline |
Forbid all network requests; serve strictly from vael.lock and the verified CAS cache. |
--no-npm |
Disable npm: and package.json resolution completely for the run. |
.npmrc Scoped Registries & Auth
Section titled “.npmrc Scoped Registries & Auth”Both vjs and vjs-lite (since 0.0.0-alpha.1) load user-level ~/.npmrc alongside project-local .npmrc discovered upward from the referrer or project directory (max 256 KiB, opened with O_NOFOLLOW on Unix so symlinks fail closed):
# Project .npmrc — non-secret registry routing ONLYregistry=https://registry.npmjs.org@internal:registry=https://npm.internal.example/# User ~/.npmrc — credentials and ${ENV_VAR} expansion belong here strictly//npm.internal.example/:_authToken=${INTERNAL_NPM_TOKEN}- Project auth isolation (
ProjectAuthNotAllowed): Project-local.npmrcacceptsregistry=and@scope:registry=routing only. Auth directives (_authToken,_auth,username,_password,always-auth,//host:keys) and${ENV_VAR}expansion are rejected in project.npmrcso untrusted repositories cannot exfiltrate host tokens; credentials and${ENV_VAR}belong strictly in~/.npmrc. - HTTPS-only: Only
https:registries are accepted forregistry=and@scope:registry=. - Lazy
${ENV_VAR}interpolation: In~/.npmrc, tokens are read only from[A-Za-z_][A-Za-z0-9_]*environment variables when a request matches that rule (no shell evaluation). - Zero secret leakage: Credentials are stored with
ZeroizeOnDrop, print as<redacted>in errors/debug output, and are stripped on cross-origin or out-of-scope redirects.
Remote jsr:, gh:, and https: Imports
Section titled “Remote jsr:, gh:, and https: Imports”Remote module loading is disabled by default in both vjs and vjs-lite (since 0.0.0-alpha.1). Enable it explicitly per invocation with --allow-remote or VAELJS_ALLOW_REMOTE=1 (and override it off with --no-allow-remote):
vjs --allow-remote https://example.com/script.tsvjs --allow-remote gh:owner/repo@v1.2.3/mod.tsvjs-lite --allow-remote https://example.com/script.tsvjs-lite --allow-remote jsr:@scope/pkg@^1.0.0jsr:@scope/name[@constraint][/subpath]: Resolves via the public JSR registry (jsr.io), checking every fetched file’s length and SHA-256 against the version manifest before type-stripping and execution.gh:owner/repo@ref/path/github:owner/repo@ref/path: Normalizes to a credential-freehttps://raw.githubusercontent.com/...URL (the legacygh:owner/repo/path/@refform is also accepted).refmust be a single path segment (tag, branch without/, or commit SHA).https://...: Plainhttp:is always rejected. The HTTPS client sends no ambient credentials and reads no proxy environment variables.
