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 <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Freddy Boulton 2024-06-13 17:26:57 -04:00 committed by GitHub
parent a4433be25c
commit 88de38e259
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 5 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/preview": patch
"gradio": patch
---
fix:Fix custom components on windows

View File

@ -64,7 +64,7 @@ def _build(
package_name = get_deep(pyproject_toml, ["project", "name"])
python_path = _get_executable_path(
"python", None, "--python-path", check_3=True
"python", python_path, "--python-path", check_3=True
)
if not isinstance(package_name, str):

View File

@ -47,7 +47,9 @@ export async function make_build({
comp.frontend_dir &&
fs.existsSync(join(comp.frontend_dir, "gradio.config.js"))
) {
const m = await import(join(comp.frontend_dir, "gradio.config.js"));
const m = await import(
join("file://" + comp.frontend_dir, "gradio.config.js")
);
component_config.plugins = m.default.plugins || [];
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];

View File

@ -157,7 +157,7 @@ async function generate_imports(
fs.existsSync(join(component.frontend_dir, "gradio.config.js"))
) {
const m = await import(
join(component.frontend_dir, "gradio.config.js")
join("file://" + component.frontend_dir, "gradio.config.js")
);
component_config.plugins = m.default.plugins || [];
@ -184,13 +184,13 @@ async function generate_imports(
);
const example = exports.example
? `example: () => import("${to_posix(
? `example: () => import("/@fs/${to_posix(
join(component.frontend_dir, exports.example)
)}"),\n`
: "";
return `${acc}"${component.component_class_id}": {
${example}
component: () => import("${to_posix(
component: () => import("/@fs/${to_posix(
join(component.frontend_dir, exports.component)
)}")
},\n`;