windmill-labs/windmill · error · UnsupportedLocalPathScriptPreviewError

Local PathScript ${filePath} requires a multi-file bundle, w

Error message

Local PathScript ${filePath} requires a multi-file bundle, which flow preview/dev cannot inline yet

What it means

In the same bundler (cli/src/utils/local_path_scripts.ts), when esbuild emits MORE than one output file for a single-entry build — i.e. the codebase compiles to a multi-file bundle (e.g. code-split or multiple assets emitted) — flow preview/dev cannot inline a single-file payload, so an UnsupportedLocalPathScriptPreviewError is thrown. The typed error name marks the case as an unsupported preview feature, not a build failure: the bundle itself is fine.

Source

Thrown at cli/src/utils/local_path_scripts.ts:70

    format: "esm",
    bundle: true,
    write: false,
    external: codebase.external,
    inject: codebase.inject,
    define: codebase.define,
    loader: codebase.loader ?? { ".node": "file" },
    outdir: "/",
    platform: "node",
    packages: "bundle",
    target: "esnext",
    banner: codebase.banner,
  });

  if (out.outputFiles.length === 0) {
    throw new Error(`No output files found for ${filePath}`);
  }
  if (out.outputFiles.length > 1) {
    throw new UnsupportedLocalPathScriptPreviewError(
      `Local PathScript ${filePath} requires a multi-file bundle, which flow preview/dev cannot inline yet`
    );
  }
  if (Array.isArray(codebase.assets) && codebase.assets.length > 0) {
    throw new UnsupportedLocalPathScriptPreviewError(
      `Local PathScript ${filePath} requires codebase assets, which flow preview/dev cannot inline yet`
    );
  }

  return out.outputFiles[0].text;
}

export function createPreviewLocalScriptReader(opts: {
  exts: string[];
  defaultTs?: "bun" | "deno";
  codebases: SyncCodebase[];
}): (scriptPath: string) => Promise<LocalScriptInfo | undefined> {
  return async (scriptPath) => {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Adjust the codebase esbuild config so the build yields exactly one JS output (disable code splitting, avoid file-emitting loaders like '.node': 'file')
  2. Use the normal sync/deploy path (`wmill sync push`) which supports multi-file codebases, instead of flow preview/dev
  3. Remove or relocate binary/native assets from the codebase, or reference them via external/CDN URLs
  4. Keep native modules as external dependencies installed at runtime rather than bundling them into outputs

Example fix

// before: codebase config emits extra files
codebase: { loader: { ".node": "file" } } // bundle + .node asset = 2 outputs

// after: keep native module external
codebase: { external: ["./native.node"] } // single JS output, preview works
Defensive patterns

Strategy: validation

Validate before calling

// check the codebase config before preview: single-file inline requires one JS output
if (codebase.loader && Object.values(codebase.loader).some((l) => l === "file")) {
  throw new Error(`Codebase for ${filePath} uses file-emitting loaders; flow preview/dev cannot inline multi-file bundles — deploy via sync instead`);
}

Type guard

function isUnsupportedPreviewError(err: unknown): err is import("./local_path_scripts.ts").UnsupportedLocalPathScriptPreviewError {
  return err instanceof Error && err.name === "UnsupportedLocalPathScriptPreviewError";
}

Try / catch

import { UnsupportedLocalPathScriptPreviewError } from "./utils/local_path_scripts.ts";
try {
  const inlined = await inlineLocalScript(scriptPath);
} catch (e) {
  if (e instanceof UnsupportedLocalPathScriptPreviewError && /multi-file bundle/.test(e.message)) {
    console.error(`${scriptPath} bundles to multiple files; use 'wmill sync push' for this codebase`);
  } else throw e;
}

Prevention

When it happens

Trigger: bundleSingleFileCodebaseScript builds a codebase-backed bun PathScript whose esbuild output contains >1 file (out.outputFiles.length > 1), reached during flow preview/dev via createPreviewLocalScriptReader's content().

Common situations: Codebase config enabling code splitting or multiple entry-like outputs; loader mapping (e.g. '.node': 'file') causing esbuild to emit companion asset files alongside the JS bundle; plugins/emit in a custom esbuild setup producing extra outputs; recently added codebase features that the single-file inline path does not support yet.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/891a9c940fb540c1. Report an issue: GitHub.