{"record":{"id":"1ac21be0f931421b","repo":"DioxusLabs/dioxus","slug":"invalid-css","errorCode":null,"errorMessage":"Invalid css","messagePattern":"Invalid css","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/manganis/manganis-macro/src/css_module.rs","lineNumber":90,"sourceCode":"        const ASSET: manganis::Asset =\n    };\n    attribute.asset_parser.to_tokens(&mut linker_tokens);\n\n    let asset = match attribute.asset_parser.asset.as_ref() {\n        Ok(path) => path,\n        Err(err) => {\n            let err = err.to_string();\n            tokens.append_all(quote! { compile_error!(#err) });\n            return;\n        }\n    };\n\n    let css = std::fs::read_to_string(asset).expect(\"Unable to read css module file\");\n\n    let mut values = Vec::new();\n\n    let hash = create_module_hash(asset);\n    let class_mappings = get_class_mappings(css.as_str(), hash.as_str()).expect(\"Invalid css\");\n\n    // Generate class struct field tokens.\n    for (old_class, new_class) in class_mappings.iter() {\n        let as_snake = to_snake_case(old_class);\n\n        let ident = Ident::new(&as_snake, Span::call_site());\n        values.push(quote! {\n            pub const #ident: #struct_name_private::__CssIdent = #struct_name_private::__CssIdent { inner: #new_class };\n        });\n    }\n\n    // We use a PhantomData to prevent Rust from complaining about an unused lifetime if a css module without any idents is used.\n    tokens.extend(quote! {\n        #[doc(hidden)]\n        #[allow(missing_docs, non_snake_case)]\n        mod #struct_name_private {\n            use dioxus::prelude::*;\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/manganis/manganis-macro/src/css_module.rs#L72-L108","documentation":"After reading the css module file, the macro parses it with manganis-core's lightweight class parser (get_class_mappings). Malformed CSS — unbalanced braces, broken selectors, nested :global() — yields a ParseError which the macro unwraps with expect(\"Invalid css\"). The generic message discards the underlying parse error details, so you must lint the file to locate the fault.","triggerScenarios":"A css module file containing syntax errors: unclosed { }, stray characters, invalid selector fragments, :global() nested inside :global(), or CSS constructs the class parser does not support.","commonSituations":"Hand-editing css module files and leaving an unbalanced brace; pasting preprocessor syntax (SCSS variables, nesting) into a plain css module; file truncated by tooling or a bad merge.","solutions":["Run the file through a CSS formatter/linter (prettier, stylelint) to pinpoint the syntax error","Balance braces and write standard flat CSS selectors and classes","Use a single level of :global(.class); never nest :global() inside :global()","Remove preprocessor-only syntax (SCSS variables, nesting, mixins) from css module files"],"exampleFix":"// before (module.css)\n.container { color: red;\n// missing closing brace\n// after\n.container { color: red; }","handlingStrategy":"validation","validationCode":"// build.rs or CI: lint css module files before compiling\nfn css_parses(path: &std::path::Path) -> bool {\n    let css = std::fs::read_to_string(path).unwrap();\n    css.matches('{').count() == css.matches('}').count()\n}\nassert!(css_parses(std::path::Path::new(\"css/module.css\")));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run prettier/stylelint on css module files in CI","Use plain flat CSS in css modules; no SCSS nesting or variables","Single-level :global(.class) only","The macro's error message is generic — always re-lint the file to find the real spot"],"tags":["manganis","css-modules","parsing","proc-macro","build"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}