{"record":{"id":"3eed7154b4d3138d","repo":"sinelaw/fresh","slug":"bundling-failed-for","errorCode":null,"errorMessage":"Bundling failed for {}: {}","messagePattern":"Bundling failed for (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-plugin-runtime/src/thread.rs","lineNumber":1475,"sourceCode":"                );\n                None\n            }\n        }\n    } else {\n        None\n    };\n\n    // Transpile/bundle to JS (same logic as QuickJsBackend::load_module_with_source)\n    let js_code = if fresh_parser_js::has_es_imports(&source) {\n        match fresh_parser_js::bundle_module(path) {\n            Ok(bundled) => bundled,\n            Err(e) => {\n                tracing::warn!(\n                    \"Plugin {} uses ES imports but bundling failed: {}. Skipping.\",\n                    path.display(),\n                    e\n                );\n                return Err(anyhow!(\"Bundling failed for {}: {}\", plugin_name, e));\n            }\n        }\n    } else if fresh_parser_js::has_es_module_syntax(&source) {\n        let stripped = fresh_parser_js::strip_imports_and_exports(&source);\n        if filename.ends_with(\".ts\") {\n            fresh_parser_js::transpile_typescript(&stripped, filename)?\n        } else {\n            stripped\n        }\n    } else if filename.ends_with(\".ts\") {\n        fresh_parser_js::transpile_typescript(&source, filename)?\n    } else {\n        source\n    };\n\n    // Load accompanying .i18n.json file\n    let i18n_path = path.with_extension(\"i18n.json\");\n    let i18n = if i18n_path.exists() {","sourceCodeStart":1457,"sourceCodeEnd":1493,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-plugin-runtime/src/thread.rs#L1457-L1493","documentation":"prepare_plugin aborts when the plugin source contains ES imports (has_es_imports) but fresh_parser_js::bundle_module fails to bundle it. The plugin is skipped (an error is returned) because without bundling the import statements cannot run in the QuickJS runtime. Typical causes are unresolvable imports, syntax errors in imported modules, or unsupported module syntax in the dependency graph.","triggerScenarios":"Thrown at crates/fresh-plugin-runtime/src/thread.rs:1475 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the import specifiers in the plugin so they resolve to existing files or supported dependencies.","Check the imported modules for syntax errors or unsupported syntax and correct them.","Rewrite the plugin to avoid ES imports (inline the code or use the runtime-provided APIs) so bundling is unnecessary.","Run the bundler standalone on the file (fresh_parser_js::bundle_module equivalent) to see the detailed bundler error and address it."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}