biomejs/biome · error
formatting embedded JavaScript snippets requires the `js_emb
Error message
formatting embedded JavaScript snippets requires the `js_embeds` feature
What it means
Panic in the embedded-formatting closure of the JavaScript handler (javascript.rs:1755-1766). When biome_service is compiled without the js_embeds cargo feature, formatting a document that contains embedded snippets (e.g. CSS or GraphQL inside JS template literals) reaches this #[cfg(not(feature = "js_embeds"))] block, which discards its arguments and panics. The feature flag exists because embedded formatting pulls in extra formatter dependencies; official Biome binaries ship with it enabled.
Source
Thrown at crates/biome_service/src/file_handlers/javascript.rs:1800
formatted.propagate_expand();
match formatted.print() {
Ok(printed) => Ok(printed),
Err(error) => Err(WorkspaceError::FormatError(error.into())),
}
}
#[cfg(not(feature = "js_embeds"))]
{
let _ = (
biome_path,
document_file_source,
parse,
settings,
embedded_nodes,
workspace_db,
);
panic!("formatting embedded JavaScript snippets requires the `js_embeds` feature")
}
}
pub(crate) fn pull_diagnostics_and_actions(
params: DiagnosticsAndActionsParams,
) -> PullDiagnosticsAndActionsResult {
let DiagnosticsAndActionsParams {
parsed_source,
settings,
language,
path,
only,
skip,
categories,
workspace_db,
project_layout,
suppression_reason,
enabled_selectors,View on GitHub (pinned to 0fca643d22)
Solutions
- Enable the feature: depend on biome_service with features = ["js_embeds"] (or default features) and rebuild
- If embedded formatting is not needed, disable it at the configuration level so format_embedded is never called with snippets (avoid formatting files containing embedded CSS/GraphQL)
- Check cargo tree -e features biome_service to confirm who is disabling the feature before blaming your own manifest
Example fix
# before
biome_service = { path = "../biome_service", default-features = false }
# after
biome_service = { path = "../biome_service", default-features = false, features = ["js_embeds"] } Defensive patterns
Strategy: validation
Validate before calling
# Cargo.toml - declare the feature explicitly
biome_service = { path = "../biome_service", features = ["js_embeds"] }
# tests/smoke.rs - fail fast if the feature is off in your build
#[test]
fn js_embeds_feature_is_enabled() {
let formatted = format_js_with_embed("const s = css`color: red;`");
assert!(formatted.is_ok(), "biome_service was built without js_embeds");
} Prevention
- Never build biome_service with default-features = false without re-enabling js_embeds when you format JS-family files
- Audit feature unification with cargo tree -e features biome_service after dependency changes
- Add a smoke test that formats a CSS-in-JS snippet to catch feature regressions in CI
When it happens
Trigger: A downstream crate builds biome_service with the js_embeds feature off (e.g. default-features = false) and then formats a JS-family document whose parse contains embedded nodes, invoking format_embedded (javascript.rs:1691) with a non-empty snippet set.
Common situations: Custom tooling that embeds biome_service and trims features for compile time/binary size; feature unification accidentally disabling defaults (another dependency pulling biome_service with default-features = false); building only parts of the workspace (cargo build -p) without the workspace's full feature set.
Related errors
- token kind {kind:?} cannot be transformed to text
- empty file
- found a token with no parent
- empty file
- found a token with no parent
AI-assisted analysis of biomejs/biome@0fca643d22 (2026-08-20).
Data as JSON: /api/errors/a47e3582cebeef25.
Report an issue: GitHub.