{"record":{"id":"f7822d69779ad2d0","repo":"swc-project/swc","slug":"cannot-process-file-because-it-s-ignored-by-swcrc","errorCode":null,"errorMessage":"cannot process file because it's ignored by .swcrc","messagePattern":"cannot process file because it's ignored by \\.swcrc","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc/src/lib.rs","lineNumber":968,"sourceCode":"        P1: Pass,\n        P2: Pass,\n    {\n        self.run(|| -> Result<_, Error> {\n            let config = self.run(|| {\n                self.parse_js_as_input(\n                    fm.clone(),\n                    program,\n                    handler,\n                    opts,\n                    &fm.name,\n                    Some(&comments),\n                    |program| custom_before_pass(program),\n                )\n            })?;\n            let config = match config {\n                Some(v) => v,\n                None => {\n                    bail!(\"cannot process file because it's ignored by .swcrc\")\n                }\n            };\n\n            let after_pass = custom_after_pass(&config.program);\n\n            let config = config.with_pass(|pass| (pass, after_pass));\n\n            let orig = if config.source_maps.enabled() {\n                self.get_orig_src_map(\n                    &fm,\n                    &config.input_source_map,\n                    config\n                        .comments\n                        .get_trailing(config.program.span_hi())\n                        .as_deref()\n                        .unwrap_or_default(),\n                    false,\n                )?","sourceCodeStart":950,"sourceCodeEnd":986,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc/src/lib.rs#L950-L986","documentation":"In Compiler::process_js_inner, config resolution returned None - which by contract means 'file should be ignored' - but processing continued to the point where a config is required, so swc bails with 'cannot process file because it's ignored by .swcrc'. A None result comes from the file matching an `exclude` pattern or matching no `test` pattern in the loaded config.","triggerScenarios":"Feeding a file to the swc compiler (CLI or API) whose path hits an .swcrc `exclude` regex like \"node_modules\" or whose extension matches no `test`, without filtering it out beforehand.","commonSituations":"\"exclude\": [\"node_modules\"] also matching src/lib/node_modules-style paths; test patterns not covering .mjs/.cjs/.jsx; build scripts globbing directories broader than the config's intent.","solutions":["Narrow the `exclude` regex (anchor it, make it path-aware) so intended files are not excluded","Extend `test` to cover the file's extension","Pre-filter input files (your own ignore logic) so ignored files never reach the compiler"],"exampleFix":"// before (.swcrc)\n{ \"exclude\": \"node_modules\" }\n// after (.swcrc)\n{ \"exclude\": \"(^|/)node_modules/\" }","handlingStrategy":"validation","validationCode":"// JavaScript - apply your own exclude/test gate before compiling\nconst excluded = new RegExp(cfg.exclude ?? '$^'); // '$^' never matches\nconst tested = cfg.test ? new RegExp(cfg.test).test(file) : true;\nif (!tested || excluded.test(file)) {\n  console.warn(`skipping ${file} (not covered by .swcrc)`);\n} else {\n  await transformFile(file, options);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Anchor exclude patterns and make them path-aware: \"(^|/)node_modules/\"","Filter inputs before invoking swc rather than relying on it to ignore","Audit exclude patterns against your real directory names"],"tags":["swc","swcrc","exclude","file-matching"],"backgroundTag":"file-excluded-by-config","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"}