{"record":{"id":"c5bfb2567f5c4349","repo":"swc-project/swc","slug":"failed-to-resolve-plugin-path-resolved-path","errorCode":null,"errorMessage":"Failed to resolve plugin path: {resolved_path:?}","messagePattern":"Failed to resolve plugin path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc/src/plugin.rs","lineNumber":266,"sourceCode":"    let mut inner_cache = crate::config::PLUGIN_MODULE_CACHE\n        .inner\n        .get()\n        .expect(\"Cache should be available\")\n        .lock();\n\n    // Populate cache to the plugin modules if not loaded\n    for plugin_config in plugins.iter() {\n        let plugin_name = &plugin_config.0;\n\n        if !inner_cache.contains(plugin_runtime, plugin_name) {\n            let resolved_path = plugin_resolver\n                .resolve(&FileName::Real(PathBuf::from(plugin_name)), plugin_name)\n                .with_context(|| format!(\"failed to resolve plugin path: {plugin_name}\"))?;\n\n            let path = if let FileName::Real(value) = resolved_path.filename {\n                value\n            } else {\n                anyhow::bail!(\"Failed to resolve plugin path: {resolved_path:?}\");\n            };\n\n            inner_cache.store_bytes_from_path(plugin_runtime, &path, plugin_name)?;\n            #[cfg(debug_assertions)]\n            tracing::debug!(\"Initialized WASM plugin {plugin_name}\");\n        }\n    }\n\n    Ok(())\n}\n","sourceCodeStart":248,"sourceCodeEnd":277,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc/src/plugin.rs#L248-L277","documentation":"While registering WASM plugins (the `jsc.experimental.plugins` list), swc resolved the plugin specifier through its resolver but the resulting FileName was not `FileName::Real` - e.g. External, Custom, or a virtual path - so there is no on-disk .wasm file to load into the plugin runtime cache (crates/swc/src/plugin.rs). A resolution failure produces the earlier wrapped context 'failed to resolve plugin path: {name}' instead.","triggerScenarios":"A plugins entry whose resolved target is not a real file: bare package names resolving to external/URL targets, symlink- or PnP-style virtual paths, or a custom Resolve implementation returning a non-Real filename.","commonSituations":"plugins: [\"@scope/my-plugin\"] where the package is not installed as a real file (yarn PnP, pnpm virtual store edges); pointing at remote URLs; bundler integrations supplying their own resolver.","solutions":["Reference the plugin by a path that resolves to a real .wasm file (relative/absolute path or package with a real main)","Verify the plugin package is installed and resolvable from the project (check node_modules layout; avoid PnP/virtual resolutions)","If you implement the Resolve trait, return FileName::Real pointing at the actual .wasm on disk"],"exampleFix":"// before (.swcrc)\n{ \"jsc\": { \"experimental\": { \"plugins\": [ [\"@scope/transform\", \"{}\"] ] } } }\n// after (.swcrc)\n{ \"jsc\": { \"experimental\": { \"plugins\": [ [\"./plugins/transform.wasm\", \"{}\"] ] } } }","handlingStrategy":"validation","validationCode":"// JavaScript - confirm each plugin resolves to a real .wasm before compiling\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\nfunction assertPluginsOnDisk(plugins) {\n  for (const [name] of plugins) {\n    let resolved;\n    try { resolved = require.resolve(name); } catch { resolved = name; }\n    if (!fs.existsSync(resolved)) {\n      throw new Error(`swc plugin does not resolve to a real file: ${name}`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer relative/absolute .wasm paths for plugins over bare specifiers","Install plugin packages with real node_modules files (avoid PnP/virtual layouts)","Verify plugin artifacts exist in CI before the compile step"],"tags":["swc","wasm-plugin","resolver","plugin-loading"],"backgroundTag":"plugin-resolution-failed","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"}