-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix cc build #6079
fix cc build #6079
Changes from 8 commits
45310c1
19d47ae
729634a
28f940b
ad78aaa
89b277e
db3a947
32da090
7888bff
aae9406
aec74eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@gradio/preview": minor | ||
"gradio": minor | ||
"gradio_test": minor | ||
--- | ||
|
||
feat:fix cc build |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,7 +191,9 @@ def delete_contents(directory: str | Path) -> None: | |
shutil.rmtree(child) | ||
|
||
|
||
def _create_frontend(name: str, component: ComponentFiles, directory: Path): | ||
def _create_frontend( | ||
name: str, component: ComponentFiles, directory: Path, package_name: str | ||
): | ||
frontend = directory / "frontend" | ||
frontend.mkdir(exist_ok=True) | ||
|
||
|
@@ -217,7 +219,7 @@ def ignore(s, names): | |
ignore=ignore, | ||
) | ||
source_package_json = json.loads(Path(frontend / "package.json").read_text()) | ||
source_package_json["name"] = name.lower() | ||
source_package_json["name"] = package_name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tweaked this so the name in the |
||
source_package_json = _modify_js_deps(source_package_json, "dependencies", p) | ||
source_package_json = _modify_js_deps(source_package_json, "devDependencies", p) | ||
(frontend / "package.json").write_text(json.dumps(source_package_json, indent=2)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import * as fs from "fs"; | |
import { join } from "path"; | ||
import { build } from "vite"; | ||
import { plugins, make_gradio_plugin } from "./plugins"; | ||
|
||
import type { PreRenderedChunk } from "rollup"; | ||
import { examine_module } from "./index"; | ||
|
||
interface BuildOptions { | ||
|
@@ -29,7 +29,7 @@ export async function make_build({ | |
|
||
const exports: string[][] = [ | ||
["component", pkg.exports["."] as string], | ||
["exmaple", pkg.exports["./example"] as string] | ||
["example", pkg.exports["./example"] as string] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. horrendous typo |
||
].filter(([_, path]) => !!path); | ||
|
||
for (const [entry, path] of exports) { | ||
|
@@ -43,23 +43,29 @@ export async function make_build({ | |
emptyOutDir: true, | ||
outDir: join(template_dir, entry), | ||
lib: { | ||
entry: join(source_dir, entry, "index.ts"), | ||
entry: join(source_dir, path), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo didn't matter however because we were looking for |
||
fileName: "index.js", | ||
formats: ["es"] | ||
}, | ||
minify: true, | ||
rollupOptions: { | ||
output: { | ||
entryFileNames: "[name].js" | ||
entryFileNames: (chunkInfo: PreRenderedChunk) => { | ||
if (chunkInfo.isEntry) { | ||
return "index.js"; | ||
} | ||
return `${chunkInfo.name.toLocaleLowerCase()}.js`; | ||
} | ||
Comment on lines
+53
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay I've changed this so we always get an |
||
} | ||
} | ||
} | ||
}); | ||
} catch (e) { | ||
console.error(e); | ||
throw e; | ||
} | ||
} | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
throw e; | ||
Comment on lines
+64
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were squashing errors in the try/catch which is why this didn't error out as it should have. This will now fail noisily if the build doesn't succeed. |
||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍