{"record":{"id":"16b5386361d2648e","repo":"swc-project/swc","slug":"no-config-matched-for-file-name","errorCode":null,"errorMessage":"no config matched for file ({name})","messagePattern":"no config matched for file \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc/src/lib.rs","lineNumber":835,"sourceCode":"\n                    return Ok(config);\n                }\n\n                let config_file = config_file.unwrap_or_default();\n                let config = config_file.into_config(Some(filename_path))?;\n\n                return Ok(config);\n            }\n\n            let config = match config_file {\n                Some(config_file) => config_file.into_config(None)?,\n                None => Rc::default().into_config(None)?,\n            };\n\n            match config {\n                Some(config) => Ok(Some(config)),\n                None => {\n                    bail!(\"no config matched for file ({name})\")\n                }\n            }\n        })\n        .with_context(|| format!(\"failed to read .swcrc file for input file at `{name}`\"))\n    }\n\n    /// This method returns [None] if a file should be skipped.\n    ///\n    /// This method handles merging of config.\n    ///\n    /// This method does **not** parse module.\n    #[cfg_attr(debug_assertions, tracing::instrument(skip_all))]\n    pub fn parse_js_as_input<'a, P>(\n        &'a self,\n        fm: Lrc<SourceFile>,\n        program: Option<Program>,\n        handler: &'a Handler,\n        opts: &Options,","sourceCodeStart":817,"sourceCodeEnd":853,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc/src/lib.rs#L817-L853","documentation":"Thrown by Compiler::try_build_config: the effective config (from a config file or the default Rc) resolved via `into_config(filename)` to None, meaning its test/exclude filters do not claim the given file. For a single-entry config one failed match immediately yields None; for multi-entry configs no entry matched. The surrounding context adds 'failed to read .swcrc file for input file at `...`'.","triggerScenarios":"Programmatic Compiler use (swc CLI paths, custom integrations) where a config exists but `test` doesn't cover the file's extension or `exclude` matches its path.","commonSituations":"Extension not covered by test patterns; exclude patterns matching more than intended; path-form mismatches (Windows separators) breaking regexes; default-config fallback when no config file was supposed to be used.","solutions":["Adjust `test`/`exclude` in the config entry so the file matches","Add an additional entry covering the file type","If the file is meant to be skipped, filter it out before invoking swc instead of relying on config matching"],"exampleFix":"// before\n{ \"test\": \"\\\\.tsx?$\", \"exclude\": \"node_modules\" }\n// after\n{ \"test\": \"\\\\.(m|c)?tsx?$\", \"exclude\": \"(^|/)node_modules/\" }","handlingStrategy":"validation","validationCode":"// JavaScript - pre-check file coverage against the active config\nfunction isFileCovered(config, filePath) {\n  const test = config.test ? new RegExp(config.test) : null;\n  const excl = config.exclude ? new RegExp(config.exclude) : null;\n  return (!test || test.test(filePath)) && !(excl && excl.test(filePath));\n}\nconst covered = (Array.isArray(cfg) ? cfg : [cfg]).some((c) => isFileCovered(c, file));\nif (!covered) throw new Error(`config does not cover ${file}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain a catch-all config entry","Extend `test` whenever you add a new file extension to the build","Log which config entry matched each file during onboarding"],"tags":["swc","swcrc","config","file-matching"],"backgroundTag":"config-file-not-matched","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}