Expand description
The !!js expression subset evaluated at config hand-off.
Upstream evaluates !!js scalars with real JavaScript against the
loader context. The expressions that actually appear in the shipped
bundles only reference process.*, so this module evaluates that
subset synchronously — at the same hand-off point as the
${{ env.NAME }} interpolation (crate::interpolate) — with a
hand-written lexer and parser. Expressions referencing injected
context (ctx.*, dshHomePath(…)) are deferred to the owning
plugin’s lazy evaluation and fail here with a clear subset error.
Supported syntax (JavaScript precedence):
- the ternary
cond ? then : else ??,||,&&with JavaScript truthiness (empty strings and zero are falsy); like JavaScript,??may not be mixed with||/&&without parentheses- strict equality
===/!==(loose==/!=is outside the subset) - unary
! - string literals in single or double quotes, decimal integers and
floats,
true/false/null/undefined - member access limited to
process.platform,process.env.NAME(unset variables areundefined), andprocess.cwd()
Values are Nodes directly; null and undefined both map to
Node::Null, which is also what ?? triggers on.
Functions§
- evaluate
- Evaluate one
!!jsexpression, reading environment variables from the process environment. - evaluate_
node - Recursively evaluate every
Node::Exprin a value tree, leaving all other nodes untouched — the expression twin ofcrate::interpolate::interpolate_node, applied when config is handed to a plugin. - evaluate_
node_ with evaluate_nodewith a caller-supplied environment lookup.- evaluate_
with - Evaluate one
!!jsexpression against a caller-supplied environment lookup, which maps a variable name to its value (Nonewhen unset).