Skip to content

Commit 88de38e

Browse files
Fix custom components on windows (#8531)
* Fix usability windows * Add config.js * Add code * revert pnpm.lock' * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent a4433be commit 88de38e

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

.changeset/slick-ducks-fry.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/preview": patch
3+
"gradio": patch
4+
---
5+
6+
fix:Fix custom components on windows

gradio/cli/commands/components/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _build(
6464
package_name = get_deep(pyproject_toml, ["project", "name"])
6565

6666
python_path = _get_executable_path(
67-
"python", None, "--python-path", check_3=True
67+
"python", python_path, "--python-path", check_3=True
6868
)
6969

7070
if not isinstance(package_name, str):

js/preview/src/build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export async function make_build({
4747
comp.frontend_dir &&
4848
fs.existsSync(join(comp.frontend_dir, "gradio.config.js"))
4949
) {
50-
const m = await import(join(comp.frontend_dir, "gradio.config.js"));
50+
const m = await import(
51+
join("file://" + comp.frontend_dir, "gradio.config.js")
52+
);
5153

5254
component_config.plugins = m.default.plugins || [];
5355
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];

js/preview/src/dev.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async function generate_imports(
157157
fs.existsSync(join(component.frontend_dir, "gradio.config.js"))
158158
) {
159159
const m = await import(
160-
join(component.frontend_dir, "gradio.config.js")
160+
join("file://" + component.frontend_dir, "gradio.config.js")
161161
);
162162

163163
component_config.plugins = m.default.plugins || [];
@@ -184,13 +184,13 @@ async function generate_imports(
184184
);
185185

186186
const example = exports.example
187-
? `example: () => import("${to_posix(
187+
? `example: () => import("/@fs/${to_posix(
188188
join(component.frontend_dir, exports.example)
189189
)}"),\n`
190190
: "";
191191
return `${acc}"${component.component_class_id}": {
192192
${example}
193-
component: () => import("${to_posix(
193+
component: () => import("/@fs/${to_posix(
194194
join(component.frontend_dir, exports.component)
195195
)}")
196196
},\n`;

0 commit comments

Comments
 (0)