{"record":{"id":"6098a50bbbe768d1","repo":"swc-project/swc","slug":"the-requested-module-specifier-does-not-provid","errorCode":null,"errorMessage":"The requested module '{specifier}' does not provide an export named '{export_name}'","messagePattern":"The requested module '(.+?)' does not provide an export named '(.+?)'","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"bindings/binding_nodejs_support_wasm/src/nodejs.rs","lineNumber":590,"sourceCode":"\nfn await_import(\n    code: &str,\n    specifier: &str,\n    with: Option<&ObjectLit>,\n    required_exports: &[String],\n) -> String {\n    let mut out = format!(\"{DYNAMIC_IMPORT_NAME}({}\", json_string(specifier));\n    if let Some(options) = import_options_to_dynamic_options(code, with) {\n        out.push_str(\", \");\n        out.push_str(&options);\n    }\n    out.push(')');\n    if !required_exports.is_empty() {\n        out.push_str(\".then((m) => { \");\n        for export_name in required_exports {\n            out.push_str(\"if (!(\");\n            out.push_str(&json_string(export_name));\n            out.push_str(\" in m)) throw new SyntaxError(\");\n            out.push_str(&json_string(&format!(\n                \"The requested module '{specifier}' does not provide an export named \\\n                 '{export_name}'\"\n            )));\n            out.push_str(\"); \");\n        }\n        out.push_str(\"return m; })\");\n    }\n    out\n}\n\nfn import_options_to_dynamic_options(code: &str, with: Option<&ObjectLit>) -> Option<String> {\n    let attributes = slice_span(code, with?.span)?;\n    Some(format!(\"{{ with: {attributes} }}\"))\n}\n\nfn default_declaration_needs_parentheses(decl: &DefaultDecl) -> bool {\n    matches!(decl, DefaultDecl::Class(class) if class.ident.is_none())","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/bindings/binding_nodejs_support_wasm/src/nodejs.rs#L572-L608","documentation":"swc_xml_parser models parsing as three phases (Start, Main, End). This error means the input ended while the parser was still in the Start phase, i.e. no root element was ever opened. It is a recoverable parse error: the parser records it (with the EOF span) in its error list and then re-processes the EOF token in the End phase, so a Document is still returned by parse_file_as_document. The error appears in the `errors: &mut Vec<Error>` out-parameter, not as a Rust panic.","triggerScenarios":"Calling swc_xml_parser::parse_file_as_document with a completely empty file, a file containing only whitespace/comments/processing instructions/doctype, or a file that was truncated before the first `<tag` was tokenized. Anything that never yields a Token::StartTag or Token::EmptyTag before Token::Eof.","commonSituations":"Templating systems that emit an empty skeleton XML file for new documents; pipelines where an upstream truncation or partial write produces an incomplete prolog; tests that feed fixture files consisting only of `<?xml ...?>` declarations; concatenating XML fragments where the root element was expected but never written.","solutions":["Inspect the reported span (it covers start_pos..last_pos of the file) and check what the input actually contains at that offset - usually it is empty or prolog-only.","Ensure the document has exactly one root element, e.g. wrap loose content in a container element or emit `<root/>` for empty documents.","If the input is produced by another process, verify it was flushed/closed completely before parsing (check file size, re-read the tail).","Treat this error kind as fatal in your pipeline: after collecting `errors`, fail when ErrorKind::UnexpectedEofInStartPhase is present because the resulting Document has no root element child."],"exampleFix":"// before: input.xml contains only a prolog\n<?xml version=\"1.0\"?>\n<!-- no root -->\n\n// after: add a single root element\n<?xml version=\"1.0\"?>\n<root>\n  <!-- content -->\n</root>","handlingStrategy":"validation","validationCode":"// After parsing, treat a missing root element as fatal:\nuse swc_xml_parser::error::ErrorKind;\n\nlet mut errors = Vec::new();\nlet doc = swc_xml_parser::parse_file_as_document(&fm, config, &mut errors)?;\nif errors\n    .iter()\n    .any(|e| matches!(e.kind(), ErrorKind::UnexpectedEofInStartPhase))\n{\n    return Err(\"input has no root element (EOF in start phase)\".into());\n}\n// cheap pre-check: does the input contain any '<' at all?\nif !src.trim_start().starts_with('<') {\n    return Err(\"not XML: no markup\".into());\n}","typeGuard":null,"tryCatchPattern":"// Not a thrown error - it arrives via the `errors` out-parameter.\n// Check the Vec and fail fast on structural kinds before consuming `doc`.\nlet structural = errors.iter().any(|e| matches!(\n    e.kind(),\n    ErrorKind::UnexpectedEofInStartPhase | ErrorKind::UnexpectedEofInMainPhase\n));\nif structural { return Err(ParseFailure::Malformed); }","preventionTips":["Generate XML through a serializer (it always emits a root element) instead of string templates.","Validate generated documents in CI with xmllint --noout before shipping.","When consuming streams, parse only after EOF so truncated inputs are never mistaken for complete documents."],"tags":["xml","parser","eof","swc","recoverable"],"backgroundTag":"unexpected-eof","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}