Skip to content

Commit 8682ab5

Browse files
xr843claude
andcommitted
fix: make example field optional in cc build
When a custom component does not export an `./example` field in its package.json, `gradio cc build` crashes because it tries to access `.gradio` on `undefined`. The dev server (dev.ts) already guards against this, but the build path was missing the same check. Fixes #13132 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 30bf54c commit 8682ab5

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

js/preview/src/build.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,18 @@ export async function make_build({
7474
join(source_dir, pkg.exports["."].gradio)
7575
]
7676
],
77-
[
78-
join(template_dir, "example"),
79-
[
80-
join(__dirname, "svelte_runtime_entry.js"),
81-
join(source_dir, pkg.exports["./example"].gradio)
82-
]
83-
]
84-
].filter(([_, path]) => !!path);
77+
...(pkg.exports["./example"]
78+
? [
79+
[
80+
join(template_dir, "example"),
81+
[
82+
join(__dirname, "svelte_runtime_entry.js"),
83+
join(source_dir, pkg.exports["./example"].gradio)
84+
]
85+
]
86+
]
87+
: [])
88+
];
8589

8690
for (const [out_path, entry_path] of exports) {
8791
try {

0 commit comments

Comments
 (0)