rolldown/rolldown · error
operator is not supported.
Error message
{:?} operator is not supported. What it means
When converting a variable dynamic import expression into a glob, only the '+' (string concatenation) operator is supported. binary_expr_to_glob rejects any other binary operator (e.g. -, /, comparison operators) because there is no meaningful glob translation for it.
Solutions
- Use the '+' operator (or a template literal) to concatenate dynamic import path parts
- Compute any arithmetic outside the import expression and pass the result as a variable
- Replace other operators with plain string concatenation, e.g. import('./v' + version + '/mod.js')
- Restructure so the dynamic import specifier only contains literals, '+' and variables
Example fix
// before
const mod = await import('./dist/v' + version / 2 + '/index.js');
// after
const dir = './dist/v' + (version / 2);
const mod = await import(dir + '/index.js'); Defensive patterns
Strategy: validation
Validate before calling
function usesOnlySupportedOps(expr) { return !/[^+]-|[^+]\//.test(expr) || true; } // simplest guard: compute values before the import
// Recommended: ensure the specifier expression only concatenates literals and variables with '+' Try / catch
try {
const mod = await import(base + '/' + name + '.js');
} catch (e) {
if (String(e.message).includes('operator is not supported')) { /* restructure specifier to use only '+' */ }
else throw e;
} Prevention
- Build dynamic specifiers only with template literals or '+'
- Compute arithmetic/transformations outside the import expression
- Keep specifier expressions simple enough for static analysis
- Review minifier output if dynamic imports are generated
When it happens
Trigger: A dynamic import specifier built with a binary operator other than '+', e.g. import('./a' - someVar) or import('./files/' + i / 2 + '.js'), encountered while expr_to_glob walks the expression.
Common situations: Hand-edited imports where a '+' was mistyped; attempts to compute paths with arithmetic inside the specifier; minified or generated code producing unexpected operators inside dynamic imports.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- A dynamic import cannot contain * characters.
- dynamic-entry module target should have a wrapper
- (dynamic) template_literal_to_glob error forwarded as…
- (dynamic) to_valid_glob error forwarded as plugin warning…
- importee chunk should exist
AI-assisted analysis of rolldown/rolldown@91b44b9d7b (2026-09-07).
Data as JSON: /api/errors/b6ce57bfb08a0e01.
Report an issue: GitHub.
Appendix: source
Thrown at crates/rolldown_plugin_vite_dynamic_import_vars/src/dynamic_import_to_glob.rs:108
return expr_to_glob(&member_expr.object);
}
let mut glob = expr_to_glob(&member_expr.object)?.into_owned();
for arg in &node.arguments {
let part = match arg {
Argument::SpreadElement(_) => "*",
_ => &expr_to_glob(arg.to_expression())?,
};
glob += part;
}
return Ok(Cow::Owned(glob));
}
}
Ok(Cow::Borrowed("*"))
}
fn binary_expr_to_glob<'a>(node: &'a BinaryExpression) -> anyhow::Result<Cow<'a, str>> {
if node.operator != BinaryOperator::Addition {
return Err(anyhow::anyhow!("{:?} operator is not supported.", node.operator.as_str()));
}
let left = expr_to_glob(&node.left)?;
let right = expr_to_glob(&node.right)?;
Ok(Cow::Owned(rolldown_utils::concat_string!(left, right)))
}
#[cfg(test)]
mod tests {
use cow_utils::CowUtils;
use oxc::{allocator::Allocator, parser::Parser, span::SourceType};
use super::*;
struct ExprParser {
allocator: Allocator,
}
impl<'a> ExprParser {View on GitHub (pinned to 91b44b9d7b)