{"record":{"id":"891a9c940fb540c1","repo":"windmill-labs/windmill","slug":"local-pathscript-filepath-requires-a-multi-file","errorCode":null,"errorMessage":"Local PathScript ${filePath} requires a multi-file bundle, which flow preview/dev cannot inline yet","messagePattern":"Local PathScript (.+?) requires a multi-file bundle, which flow preview/dev cannot inline yet","errorType":"exception","errorClass":"UnsupportedLocalPathScriptPreviewError","httpStatus":null,"severity":"error","filePath":"cli/src/utils/local_path_scripts.ts","lineNumber":70,"sourceCode":"    format: \"esm\",\n    bundle: true,\n    write: false,\n    external: codebase.external,\n    inject: codebase.inject,\n    define: codebase.define,\n    loader: codebase.loader ?? { \".node\": \"file\" },\n    outdir: \"/\",\n    platform: \"node\",\n    packages: \"bundle\",\n    target: \"esnext\",\n    banner: codebase.banner,\n  });\n\n  if (out.outputFiles.length === 0) {\n    throw new Error(`No output files found for ${filePath}`);\n  }\n  if (out.outputFiles.length > 1) {\n    throw new UnsupportedLocalPathScriptPreviewError(\n      `Local PathScript ${filePath} requires a multi-file bundle, which flow preview/dev cannot inline yet`\n    );\n  }\n  if (Array.isArray(codebase.assets) && codebase.assets.length > 0) {\n    throw new UnsupportedLocalPathScriptPreviewError(\n      `Local PathScript ${filePath} requires codebase assets, which flow preview/dev cannot inline yet`\n    );\n  }\n\n  return out.outputFiles[0].text;\n}\n\nexport function createPreviewLocalScriptReader(opts: {\n  exts: string[];\n  defaultTs?: \"bun\" | \"deno\";\n  codebases: SyncCodebase[];\n}): (scriptPath: string) => Promise<LocalScriptInfo | undefined> {\n  return async (scriptPath) => {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/utils/local_path_scripts.ts#L52-L88","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","solutions":["Adjust the codebase esbuild config so the build yields exactly one JS output (disable code splitting, avoid file-emitting loaders like '.node': 'file')","Use the normal sync/deploy path (`wmill sync push`) which supports multi-file codebases, instead of flow preview/dev","Remove or relocate binary/native assets from the codebase, or reference them via external/CDN URLs","Keep native modules as external dependencies installed at runtime rather than bundling them into outputs"],"exampleFix":"// before: codebase config emits extra files\ncodebase: { loader: { \".node\": \"file\" } } // bundle + .node asset = 2 outputs\n\n// after: keep native module external\ncodebase: { external: [\"./native.node\"] } // single JS output, preview works","handlingStrategy":"validation","validationCode":"// check the codebase config before preview: single-file inline requires one JS output\nif (codebase.loader && Object.values(codebase.loader).some((l) => l === \"file\")) {\n  throw new Error(`Codebase for ${filePath} uses file-emitting loaders; flow preview/dev cannot inline multi-file bundles — deploy via sync instead`);\n}","typeGuard":"function isUnsupportedPreviewError(err: unknown): err is import(\"./local_path_scripts.ts\").UnsupportedLocalPathScriptPreviewError {\n  return err instanceof Error && err.name === \"UnsupportedLocalPathScriptPreviewError\";\n}","tryCatchPattern":"import { UnsupportedLocalPathScriptPreviewError } from \"./utils/local_path_scripts.ts\";\ntry {\n  const inlined = await inlineLocalScript(scriptPath);\n} catch (e) {\n  if (e instanceof UnsupportedLocalPathScriptPreviewError && /multi-file bundle/.test(e.message)) {\n    console.error(`${scriptPath} bundles to multiple files; use 'wmill sync push' for this codebase`);\n  } else throw e;\n}","preventionTips":["Disable code splitting and multi-output settings in codebases used by previewed flow steps","Keep native/binary files out of previewed codebases (or mark them external)","Reserve multi-file codebases for sync-deployed scripts, not inlined flow steps","After changing a codebase's esbuild config, run the build once and assert a single output file before using flow dev"],"tags":["esbuild","bundling","cli","unsupported-feature","local-scripts"],"backgroundTag":"multi-file-bundle-unsupported-in-preview","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}