sinelaw/fresh · error

Bundling failed for

Error message

Bundling failed for {}: {}

What it means

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.

Solutions

  1. Fix the import specifiers in the plugin so they resolve to existing files or supported dependencies.
  2. Check the imported modules for syntax errors or unsupported syntax and correct them.
  3. Rewrite the plugin to avoid ES imports (inline the code or use the runtime-provided APIs) so bundling is unnecessary.
  4. Run the bundler standalone on the file (fresh_parser_js::bundle_module equivalent) to see the detailed bundler error and address it.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/fresh-plugin-runtime/src/thread.rs:1475 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13). Data as JSON: /api/errors/3eed7154b4d3138d. Report an issue: GitHub.

Appendix: source

Thrown at crates/fresh-plugin-runtime/src/thread.rs:1475

                );
                None
            }
        }
    } else {
        None
    };

    // Transpile/bundle to JS (same logic as QuickJsBackend::load_module_with_source)
    let js_code = if fresh_parser_js::has_es_imports(&source) {
        match fresh_parser_js::bundle_module(path) {
            Ok(bundled) => bundled,
            Err(e) => {
                tracing::warn!(
                    "Plugin {} uses ES imports but bundling failed: {}. Skipping.",
                    path.display(),
                    e
                );
                return Err(anyhow!("Bundling failed for {}: {}", plugin_name, e));
            }
        }
    } else if fresh_parser_js::has_es_module_syntax(&source) {
        let stripped = fresh_parser_js::strip_imports_and_exports(&source);
        if filename.ends_with(".ts") {
            fresh_parser_js::transpile_typescript(&stripped, filename)?
        } else {
            stripped
        }
    } else if filename.ends_with(".ts") {
        fresh_parser_js::transpile_typescript(&source, filename)?
    } else {
        source
    };

    // Load accompanying .i18n.json file
    let i18n_path = path.with_extension("i18n.json");
    let i18n = if i18n_path.exists() {

View on GitHub (pinned to 67894ca546)