oven-sh/bun · error · Error
build-prefixes.js: could not find the Features bitflags! blo
Error message
build-prefixes.js: could not find the Features bitflags! block in src/css/targets.rs
What it means
build-prefixes.js regenerates the CSS `Features` bitflags block inside src/css/targets.rs. It locates the block by the marker comment `/// Autogenerated by build-prefixes.js` inside a `bitflags::bitflags! {` wrapper; if the regex no longer matches, it refuses to write rather than corrupting the file.
Source
Thrown at src/css/build-prefixes.js:535
` /// Autogenerated by build-prefixes.js`,
` /// Features to explicitly enable or disable.`,
` #[derive(Debug, Clone, Copy, PartialEq, Eq)]`,
` pub struct Features: u32 {`,
...scalar.map((f, i) => ` const ${f.toUpperCase().padEnd(pad)} = 1 << ${i};`),
``,
...groups.flatMap(([name, members], i) => {
const body = members.map(m => `Self::${m.toUpperCase()}.bits()`).join("\n | ");
const line = ` const ${name.toUpperCase()} = ${body};`;
return i > 0 ? [``, line] : [line];
}),
` }`,
`}`,
].join("\n");
let targets = fs.readFileSync("src/css/targets.rs", "utf8");
const re = /bitflags::bitflags! \{\n \/\/\/ Autogenerated by build-prefixes\.js(?:.|\n)+?\n \}\n\}/;
if (!re.test(targets)) {
throw new Error("build-prefixes.js: could not find the Features bitflags! block in src/css/targets.rs");
}
targets = targets.replace(re, lines);
fs.writeFileSync("src/css/targets.rs", targets);
await rustfmt("src/css/targets.rs");
console.log("wrote src/css/targets.rs (Features block)");
}
// ─── prefixes.rs ──────────────────────────────────────────────────────────
{
const variants = [...new Set([...p.keys()].flat().map(enumify))].sort();
const arms = [];
for (const [features, versions] of p) {
const pats = features.map(enumify).join("\n | ");
const body = [];
for (const [name, pfx] of Object.entries(versions)) {
const inner = [];
for (const [prefix, [min, max]] of Object.entries(pfx)) {
if (!prefixConst[prefix]) throw new Error("Missing prefix " + prefix);View on GitHub (pinned to 8c5296ac45)
Solutions
- Restore the block structure: start with `bitflags::bitflags! {` followed by ` /// Autogenerated by build-prefixes.js` and close with the matched braces so the regex /bitflags::bitflags! \{\n \/\/\/ Autogenerated by build-prefixes\.js[\s\S]+?\n \}\n\}/ matches.
- Never edit inside the autogenerated Features region — add new flags to the generator (build-prefixes.js) instead.
- If targets.rs is too far gone, `git checkout src/css/targets.rs` and rerun the generator.
Defensive patterns
Strategy: validation
Validate before calling
const re = /bitflags::bitflags! \{\n \/\/\/ Autogenerated by build-prefixes\.js(?:.|\n)+?\n \}\n\}/;
const targets = fs.readFileSync("src/css/targets.rs", "utf8");
if (!re.test(targets)) throw new Error("targets.rs: autogenerated Features block marker missing/modified"); Prevention
- Never hand-edit the autogenerated Features block in src/css/targets.rs — change build-prefixes.js instead.
- Keep the marker comment `/// Autogenerated by build-prefixes.js` on its own line right after the bitflags! brace.
- Exclude targets.rs's generated region from editor auto-format-on-save.
When it happens
Trigger: Hand-editing or reformatting the autogenerated Features block in src/css/targets.rs so the marker comment or the `\n }\n}` block structure changed, moved, or was deleted.
Common situations: Running rustfmt with different settings over targets.rs, resolving a merge conflict in the block by rewriting it, or manually adding a feature flag inside the autogenerated region.
Related errors
- Missing prefix ${prefix}
- Virtual CSS module not found: ${path}
- file did not exist after write: ${outputPath}
- Builtin Bundler: do not use import.meta.require() (in ${file
- Errors in ${entrypoint}: ${errors.map(x => x[1]).join("\n")}
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/c09fe0575384b974.
Report an issue: GitHub.